Dividing the image into blocks
Mostrar comentarios más antiguos
I have a image that I want to divide into blocks until each pixel in block have same value. For example in the link below I have an image
The image consists of waters ,leaves and green parts. I want to keep dividing into blocks until it contains the same value.
Please help.
4 comentarios
Jurgen
el 27 de Nov. de 2012
You mean each pixel _exactly _the same? there might not even be such a block in your image. Plus what do you mean with dive into?
Jan
el 27 de Nov. de 2012
I do not see any picture on the linked page, but a lot of advertisments.
kash
el 27 de Nov. de 2012
Editada: Image Analyst
el 12 de Sept. de 2018
Image Analyst
el 27 de Nov. de 2012
I didn't see a picture immediately either. When I clicked on the download link, my company threw up a page that says they've forbidden us to go to that web site. Please pick a site where we can see the image immediately, like tinypic.com or dozens of others.
What do you mean "grouped" or "in a block"? I think of a block as rectangular - what if your contiguous set of gray levels is not rectangular? Can you have blob-shaped "blocks"? If so are you talking about connected components labeling like done with bwlabel and bwconncomp?
Respuestas (2)
Image Analyst
el 27 de Nov. de 2012
kash, I know you've been doing image processing for over a year now and I know you know about bwlabel() and bwconncomp(), so tell me why doing something like
labeled67blobs = bwlabel(grayImage == 67); % Similar for any other number.
is not doing what you want?
Salma Hassan
el 11 de Sept. de 2018
Editada: Walter Roberson
el 11 de Sept. de 2018
i=imread('image_1_0.png');
i=imresize(i,[256 256]);
a=64; b=64; %window size
x=size(i,1)/a; y=size(i,2)/b;
m=a*ones(1,x); n=b*ones(1,y);
C =mat2cell(i,m,n);
C = C(:);
%# display tiles i subplots
for j=1:a*b
block_image = mean2(C{j});
if block_image > 10
imshow( C{j} )
end
end
5 comentarios
Walter Roberson
el 12 de Sept. de 2018
That will only display the last image for which the mean is large enough. imshow() will be called for the others, but will delete the axes and queue the new image for rendering, but the rendering will not happen until figure() or pause() or uiwait() or waitfor() or drawnow() is called, or until MATLAB returns to the keyboard, and since none of those happen inside the loop, each previous request to render will be zapped by the axes deletion that imshow() does, leaving only the final request to be rendered.
Using image() instead of imshow() would not delete the axes, but since hold is not on, image() would replace the content of the axes, and the visual result would be pretty much the same, that only the last of the requests would update the screen.
Image Analyst
el 12 de Sept. de 2018
When the poster says "I want to divide into blocks until each pixel in block have same value." he's basically describing either quadtree decomposition, done by function qtdecomp(), or superpixels, done by the function superpixels(). The code in this answer just divides into rectangular blocks of all the same size, and each block does not necessarily have all the same value.
djeffal khaled
el 20 de Nov. de 2018
what is the n variable?
suha athab
el 30 de Nov. de 2018
Editada: Image Analyst
el 30 de Nov. de 2018
Your code is very useful for me, but I wonder, if I can display only the block with maximum mean value, what will I do? Please answer me.
Image Analyst
el 30 de Nov. de 2018
It is not necessary that you do ONLY that. You can do whatever you want. You can keep track of the means for all block and display only the single block that has the highest mean if you want. See my attached blockproc demos.
Categorías
Más información sobre Neighborhood and Block Processing en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!