MATLAB Image processing filtering

One sample image is http://goo.gl/0IOkBZy .Download the file and name it as
My code is
Now here , I am getting two regions, one the small area (1) and the other as the big one (2)

 Respuesta aceptada

Walter Roberson
Walter Roberson el 15 de En. de 2016

1 voto

bwareafilt() if you have a newer MATLAB. If not then regionprops() 'Area' and select only the smaller of the two regions.

3 comentarios

Rusty
Rusty el 15 de En. de 2016
Thank you for answering. There was a slight error in the question.I have corrected it. The problem is that I may not get only 2 regions always. The bigger region may get split in to 2 or three parts because of value of threshold chosen. please help. Thanks :)
Walter Roberson
Walter Roberson el 15 de En. de 2016
Editada: Walter Roberson el 15 de En. de 2016
Look at the eccentricity of the region. The split regions are probably not going to be as circular as the region you want.
Also, image dilation would have a good chance of joining back together the split large region long before the dilation reached the region of interest.
Rusty
Rusty el 15 de En. de 2016
Actually I am new to image processing. I also tried image dilation and image erosion but I failed. Could you please help me more?

Iniciar sesión para comentar.

Más respuestas (2)

Image Analyst
Image Analyst el 15 de En. de 2016
For that particular image, you can use
labeledImage = bwlabel(binaryImage);
smallBlob = ismember(labeledImage, 2) > 0;
In general somehow you have to identify the blob you want, then use ismember() to extract it. For this one, I know that you have only 2 blobs and that the small inside one will be blob #2 because of the way it does labeling. But in general (like your second image), you may have to use regionprops() to get other measurements to identify the particular blob(s) you want, and then use ismember(). See my Image Segmentation Tutorial http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862 for examples of that where I pick out different coins in the image.
You may also want to learn about bwareafilt() or bwselect().

7 comentarios

Rusty
Rusty el 15 de En. de 2016
Sir, Can you please help me in doing this using watershed?
Image Analyst
Image Analyst el 15 de En. de 2016
That would not apply for the set of input and output binary images you showed. Who told you that it would?
Rusty
Rusty el 16 de En. de 2016
Sir, I thought that we can use watershed on the input image, which is not binary but rgb. (( after converting it into grayscale image). Please clear my doubt about this. I applied the algorithms given here I was getting something.
Image Analyst
Image Analyst el 16 de En. de 2016
Watershed is used for splitting apart blobs that are connected together. In your examples, you don't show any like that. All your blobs are separate - not touching - so you don't need it.
Rusty
Rusty el 16 de En. de 2016
But in some cases the blob is near the bigger wall. So when I am using this algorithm I have formed, the small blob merges with the bigger one. So , please guide me for that. I have used your segamentation tutorial and have formed an algorithm, you can see the video of my simulations here : https://goo.gl/kWd88X.
But please guide me for watershed algorithm . Thanks
Image Analyst
Image Analyst el 16 de En. de 2016
But you never posted any image where they were connected. Anyway, if you do have images like that, you can split them apart with code Steve put on his blog: http://blogs.mathworks.com/steve/2013/11/19/watershed-transform-question-from-tech-support/ Please try Steve's code on your image and if you can't tweak it enough to get it working, then post that image and your script back here.
Rusty
Rusty el 16 de En. de 2016
Sir, I have posted the new image ( in which I am facing problem). Please have a look at it. Thanks

Iniciar sesión para comentar.

harjeet singh
harjeet singh el 16 de En. de 2016
try to use this code for these type of image, but not for every slice
clear all
close all
clc
img=imread('ok2.jpg');
img=rgb2gray(img);
img1=img>mean(img(:));
img2=imfill(img1,'holes');
se=strel('disk',2);
img2=imdilate(img2,se);
img3=img2 & ~img1;
img4=imfill(img3,'holes');
img5=img4 & ~img3;
img6=bwareaopen(img5,100);
figure(7)
imshow(img6)

3 comentarios

Rusty
Rusty el 16 de En. de 2016
Thank you
harjeet singh
harjeet singh el 16 de En. de 2016
is this works for you?
Rusty
Rusty el 16 de En. de 2016
Actually I did something else. YOu can see a video of my simulation: at https://goo.gl/kWd88X. I use the methods told by imageAnalyst in his tutorials. Could you please help me solving this algorithm using watershed?

Iniciar sesión para comentar.

Preguntada:

el 15 de En. de 2016

Editada:

el 17 de En. de 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by