flood fill algorithm in computer graphics

Поділитися
Вставка
  • Опубліковано 10 жов 2024
  • In this video we will learn about flood fill algorithm in computer graphics.
    BASIC CONCEPT:
    Flood fill algorithm is useful in cases where there no single color boundary for the polygon, i.e. the boundary has multiple colors.
    In flood fill algorithm instead of filling color till you encounter a specific boundary color you just fill the pixels with default color.
    It is used in the "bucket" fill tool of paint programs to fill connected, similarly-colored areas with a different color
    Algorithm:
    Flood-fill (node, target-color, replacement-color):
    1. If target-color is equal to replacement-color, return.
    2. If the color of node is not equal to target-color, return.
    3. Set the color of node to replacement-color.
    4. Perform Flood-fill (one step to the south of node, target-color, replacement-color).
    Perform Flood-fill (one step to the north of node, target-color, replacement-color).
    Perform Flood-fill (one step to the west of node, target-color, replacement-color).
    Perform Flood-fill (one step to the east of node, target-color, replacement-color).
    5. Return.
    Methods of Implementation:
    There are two methods in which the Flood-Fill Algorithm can be implemented:
    4-connected pixel
    8-connected pixel
    4-connected pixel
    In 4 connected pixel method you check 4 pixels adjacent to the current pixel, namely towards the North(top), South(bottom), west(left), East(right).
    So you fill the area with 4-connected pixel method by following these steps
    Step 1: First initialize the 4 values namely x, y, Fill-color & Default-color. Where x and y are co-ordinate positions of the initial interior pixel we start the flood fill algorithm & Fill-color is the color we want to fill and Default-color is the default color of the interior pixel
    Step 2: If the color of node is not equal to default-color, return.
    Step 3: Set the color of node to replacement-color.
    Step 4: Set the color of node to the south of node to replacement-color.
    Step 5: Set the color of node to the north of node to replacement-color.
    Step 6: Set the color of node to the east of node to replacement-color.
    Step 7: Set the color of node to the west of node to replacement-color.
    Step 8: Exit.
    Boundary fill algorithm: • boundary fill algorith...
    PLEASE SUBSCRIBE!!!!!
    LIKE AND SHARE THIS VIDEO.
    THANK YOU!!!

КОМЕНТАРІ • 44

  • @shivanshgupta3770
    @shivanshgupta3770 6 років тому +26

    You are using a recursive (depth first search) solution. It should not have any problem whether we use 4-connected or 8-connected. It will always fill the whole figure

    • @vncsdev
      @vncsdev 6 років тому +1

      I think there are some cases where, if you use an 8-connected algorithm, it connects to a pixel outside the polygon if its border is of 1 stroke only.

    • @luckyrai7553
      @luckyrai7553 6 років тому +1

      Vinicius I think if the default color would be same to outside color then only u will get the problem u states above

  • @AlexRoy-h9s
    @AlexRoy-h9s Рік тому +2

    Hey you are asking us to subscribe if we find this video genuine. Thnx for keeping it honest. Your videos helped me very much to understand the concepts clearly and prepare well for my exams. Please keep making more videos to help us students. Thnk you sir for putting in the time and effort 😄

  • @vishnus2567
    @vishnus2567 5 років тому +3

    Does this flood fill algorithm is wright?
    Void FloodFill(int x, int y, int Default_Colour, int Replacement_Colour)
    {
    If(getpixel(x, y)==Default_Colour )
    {
    Putpixel(x, y, Replacement_colour) ;
    FloodFill(x+1, y, Default_Colour, Replacement_Colour) ;
    FloodFill(x, y+1, Default_Colour, Replacement_Colour) ;
    FloodFill(x-1, y, Default_Colour, Replacement_Colour) ;
    FloodFill(x, y-1, Default_Colour, Replacement_Colour) ;
    }
    }

  • @luckyrai7553
    @luckyrai7553 6 років тому +3

    All pixels will be coloured in 4 connected as u are using recursive algo so in each step ,algo will consider 4 directions and no problem would be there.

  • @escape2music
    @escape2music 3 роки тому +3

    Thank u so much for making this video very useful me for the right time☺💟💟💗

  • @pratyushsharma6655
    @pratyushsharma6655 6 років тому

    I understood the theory from your videos but where can I find an example, like if I asked to fill a given polygon figure to fill with scan line or boundary/flood fill algorithms in exam ? They asked that btw in class test with scan line and I was confused how many times to repeat the scan line bcz it should be equal to vertical resolution and it was not given ?

  • @nirvikranjandas6200
    @nirvikranjandas6200 4 роки тому

    How to check that whether current colour is boundary colour? Since we are taking inputs as node target colour and replacement colour

  • @shagunsingla5292
    @shagunsingla5292 5 років тому +1

    Can you tell me like tbrl which approach is used in 8 con. Flood fill and boundary fill algo?

  • @dicethemann
    @dicethemann 6 років тому

    Is there any constant order in which the cells are filled ??

  • @mayukhmajumdarblogs9383
    @mayukhmajumdarblogs9383 3 роки тому +1

    Very nice video please make a video of Q Basic

  • @ashwinchandore7536
    @ashwinchandore7536 6 років тому +3

    very useful video.....i understand concept

    • @QuickCS
      @QuickCS  6 років тому

      Glad you found it useful. Please subscribe and share it with friends

  • @kishanikandasamy
    @kishanikandasamy 3 роки тому

    What is the use of recursion here?

  • @vishnus2567
    @vishnus2567 5 років тому

    What is the need for step 1. Step 1 and step 2 same?

  • @ASPIRANT_IN_ACTION
    @ASPIRANT_IN_ACTION 6 років тому +2

    Sir please explain the differences clearly because i have my sememster in two days
    And could u pls make a video for the following topics
    Interactive hardware and software techniques
    Graphic monitors and workstations

    • @QuickCS
      @QuickCS  6 років тому

      Muthu raman your want to know the difference between what? Please ask specific question

    • @ASPIRANT_IN_ACTION
      @ASPIRANT_IN_ACTION 6 років тому +2

      Difference between flood fill and boundary fill algorithms

  • @satabdiacharya7744
    @satabdiacharya7744 6 років тому +1

    Good and clear explanation

    • @QuickCS
      @QuickCS  6 років тому

      Thanks glad you liked it. Please Subscribe!!!

  • @anjalidubey2996
    @anjalidubey2996 6 років тому

    Fence fill algorithm ke upper video bnayiye

  • @omkarbarge5103
    @omkarbarge5103 6 років тому +1

    cool bro!!! it is very helpfu within 10 minutesl !!

  • @ibadshaikh2215
    @ibadshaikh2215 5 років тому

    you saved my paper bro

  • @rafeedafaisaltk2117
    @rafeedafaisaltk2117 3 роки тому

    Well explained

  • @soniyapal1701
    @soniyapal1701 6 років тому +1

    well explanation sir thanku

    • @QuickCS
      @QuickCS  6 років тому +1

      Glad you found it useful. Please Subscribe and share with your friends. Thank you

  • @anonymous2684
    @anonymous2684 5 років тому

    Can you make a prg for it

  • @shagunsingla5292
    @shagunsingla5292 5 років тому +1

    Good

  • @Gods_fellowship
    @Gods_fellowship 6 років тому

    super xplanation sir

  • @shribhandari3487
    @shribhandari3487 6 років тому

    good work

  • @luckyrai7553
    @luckyrai7553 6 років тому

    Plz reply to clear my doubt.

  • @shaikanif6814
    @shaikanif6814 6 років тому

    We don't you have only 2.5k it shocking

  • @somiljain5878
    @somiljain5878 5 років тому

    Exam me aa gaya to kya likh ke aana hai?

  • @harshadashimpi8819
    @harshadashimpi8819 3 роки тому +1

    Pls make video in hindi

    • @QuickCS
      @QuickCS  3 роки тому +1

      already made. here is the link: ua-cam.com/video/V1OE5mhHO4Q/v-deo.html

  • @elitexception9828
    @elitexception9828 5 років тому

    Address btana apna

  • @SunilKumar-fc6yz
    @SunilKumar-fc6yz 6 років тому +2

    Please bhai, Hindi me Bnao Video

    • @QuickCS
      @QuickCS  6 років тому

      Jaldi hi upload kar dunga.

    • @QuickCS
      @QuickCS  6 років тому

      Bhai, tumhare liye urgent video in Hindi: ua-cam.com/video/V1OE5mhHO4Q/v-deo.html . All the best👍

    • @SunilKumar-fc6yz
      @SunilKumar-fc6yz 6 років тому +1

      QuickCS Thnku Bhai, love you, kahan se ho, gujrat ya Maharashtra

    • @QuickCS
      @QuickCS  6 років тому +1

      No problem. All the best for your exams.Agar ho sake toh Channel Share karo apne dosto ke sath. Thank you,

    • @SunilKumar-fc6yz
      @SunilKumar-fc6yz 6 років тому +1

      QuickCS done