Removing noise from the image

8 views (last 30 days)

I guess i have posted this earlier.

I have number of images in a folder. I have to crop those images(without using manual cropping). Now I have changed the images to binary images so that I can perform automatic cropping. Now, when I converted the images to their binary form, I am getting some noise which is preventing me from performing the cropping step. How can I remove the noise from each images? Please Help.

Example:-

I have this original image:-

I have converted the above image image to its binary form for cropping.

Now I found that there is a noise present at the bottom left corner of the binary image. How can I remove the noise such that the black colour of noise becomes white in colour.Please help.!

Also, since I have different images in my folder, the shape of the noise portion is also different in different images.How can I remove such noises from those images as well.??? Thanx in advance

Accepted Answer

dhwani contractor
dhwani contractor on 8 Apr 2017
I am getting this result by following code...Hope this helps
I=rgb2hsv(RGBimg);
I1=I(:,:,2); % change to hsv and select the channel with most clear contrast between object and shadow
thresholded = I1 < 0.35;
SE = strel('disk',9);
IM2 = imerode(thresholded,SE);
imshow(IM2);
  1 Comment
Kumar Arindam Singh
Kumar Arindam Singh on 8 Apr 2017
thanx a lot.... can u plzz help me ....i wanted to crop these images..... say for example i wanted to crop the original image and the output would be:-

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 8 Apr 2017
Not sure why you accepted it if it's not working for you. You shouldn't use imerode(). You should use bwareafilt() instead. Then you can call regionprops() to get the bounding box, or use all() and indexing. Then use imcrop(). See my Image Segmentation Tutorial: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862&sort=downloads_desc
  2 Comments
Kumar Arindam Singh
Kumar Arindam Singh on 8 Apr 2017
the code is working... that's y i thought of accepting the answer...okay i will see the tutorial
Image Analyst
Image Analyst on 8 Apr 2017
Edited: Image Analyst on 8 Apr 2017
Well it's not doing the cropping like you wanted and the erosion will change the shape of the mask. Basically (untested)
hsvImage = rgb2hsv(rgbImage);
saturationImage = hsvImage(:,:,2);
leafMask = saturationImage > 0.35;
leafMask = bwareafilt(leafMask, 1);
leafMask = imfill(leafMask, 'holes');
labeledImage = bwlabel(leafMask);
props = regionprops(labeledImage, 'BoundingBox');
boundingBox = props.BoundingBox;
croppedImage = imcrop(rgbImage, boundingBox);

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!