Help Please Looking for error in this code...I tried for 6 hours...but i am failed to find an error.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Image Analyst
el 5 de Mayo de 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.
Respuestas (1)
Image Analyst
el 6 de Mayo de 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 comentario
Image Analyst
el 6 de Mayo de 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');
Ver también
Categorías
Más información sobre Image Processing Toolbox en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!