Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.


Jeff
Posts:
107
Registered:
2/27/10


Re: A BIG problem with simple one
Posted:
Jan 20, 2012 1:00 PM


"camilla belle" <camilla.belle@poczta.wp.pl> wrote in message <jf9sho$ich$1@newsfeed1.man.lodz.pl>... > Hi. > > > I have indexed image. Let it be a 10 x 10 matrix , which is filled randomly > with 1 or 2. Then i put randomly a 3 into the matrix. > 1 is black, 2 is white and 3 is red, later i use 4 for gray. Imagine it as > rocks , grass , fire and ash. And now i would like to burn all the grass. > So we have : > > 1 1 1 1 1 1 1 1 1 > 1 1 2 2 2 2 2 2 2 > 2 1 2 2 1 1 2 1 1 > 2 1 2 3 1 1 1 1 1 > 1 1 1 1 1 1 1 3 3 > * > > My algorithm is the simplest and only one i could think off. > 1.Compare all pixels from A to 3 > 2. Save coordinates of pixels==3 in array B. > 3.For all rows of B do: > a)get coordinates of pixel P1 and start checking all 8 neighbours > b)if neigbour is ==2 make it 3 > c)set pixel P1 to 4 which means burned > > 4.Repeat from 1. > > I am new in programming, matlab , algorithms and image processing . I would > like to know what is the fastest possible algorithm for this problem or > similar one( when we have only binary image and we want to set all whites to > black). Also could anyone write from what domain is this problem ? Is it > skeletization , dilatation, erozion , maybe i must use morfological > operation on arrays and so on..... ??? > > I am asking for help because when i use large matrix like 500x500 , well it > could take ages to see the result. > > Also i wrote algorithm using while , for ... etc. But i know that in matlab > everything is an array and that's why a man can write code only with arrays > operation , would it be faster? How i can do that ? > > Thanks . Karl.
Could you simplify this problem to just two binary images of "grass" and "fire"? Taking a simple 1x3 array, with fire: 0 1 0 and grass: 1 0 0
dilate the fire to get: 1 1 1 remove the original fire: 1 0 1 find the overlap of the new potential fire with grass to get the new fire: 1 0 0 and remove the new fire from the original grass to get: 0 0 0
If this describes your situation, using imdilate and logical operators should get you what you need.



