Help Please Looking for error in this code...I tried for 6 hours...but i am failed to find an error.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
This is code....Thresholding function is working correctly...but after thresholding i applied Morphological opening and closing of which result is not displayed. code is.
%filtim1 is input grayscale image.
imageforT = filtim1;
image_thresholded = uint8(zeros(size(imageforT)));
image_thresholded(imageforT >1) =255;
subplot(3,2,4);
imshow(image_thresholded,[]);
title('thresholded image');
st=strel('square',11);
MorphoOpen=imopen(image_thresholded,st);
MorphoClose=imclose(MorphoOpen,st);
subplot(3,2,5);
imshow(MorphoClose,[]);
title('Morphological Close');
%======================
ImageFilled = imfill(MorphoClose,'holes');
subplot(3,2,6);
imshow(ImageFilled,[]);
title('Fill Image');
2 Kommentare
Image Analyst
am 5 Mai 2014
I fixed your code formatting for you this time, but I'd like you to see this: http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup so you can do it yourself next time.
Antworten (1)
Image Analyst
am 6 Mai 2014
This line here:
image_thresholded(imageforT > 1) = 255;
sets every non-zero pixel to 255. So what it looks like depends on how many pixels in your input image are exactly zero. For me, and the cameraman standard demo image, it gave a completely white image, because there are no zero pixels. By not attaching your image, you've delayed any response that I might have given now. Do you consider anything more than 1 the foreground? Please attach your image so we can finish this.
1 Kommentar
Image Analyst
am 6 Mai 2014
By the way, it does work if you use a different image and change the thresholding method and value:
%filtim1 is input grayscale image.
filtim1 = imread('saturn.png');
if ndims(filtim1) >= 3
filtim1 = rgb2gray(filtim1);
end
subplot(3,2,1);
imshow(filtim1,[]);
title('Original image');
% Let's compute and display the histogram.
[pixelCount, grayLevels] = imhist(filtim1);
subplot(3, 2, 2);
bar(grayLevels, pixelCount);
grid on;
title('Histogram of original image', 'FontSize', fontSize);
xlim([0 grayLevels(end)]); % Scale x axis manually.
imageforT = filtim1;
image_thresholded = imageforT > 50;
subplot(3,2,4);
imshow(image_thresholded,[]);
title('thresholded image');
st=strel('square',11);
MorphoOpen=imopen(image_thresholded,st);
MorphoClose=imclose(MorphoOpen,st);
subplot(3,2,5);
imshow(MorphoClose,[]);
title('Morphological Close');
%======================
ImageFilled = imfill(MorphoClose,'holes');
subplot(3,2,6);
imshow(ImageFilled,[]);
title('Fill Image');
Siehe auch
Kategorien
Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!