How to Enter Rational Threshold Value

1 vue (au cours des 30 derniers jours)
Murat Kocaman
Murat Kocaman le 25 Fév 2018
Commenté : Murat Kocaman le 27 Fév 2018
Hello,
I would like to add rational thresholding value on my code. The related line is as below:
strel('disk',8);
is it possible to make 8 rational value 7.8 or 7.85-7.982 etc.

Réponses (2)

Image Analyst
Image Analyst le 25 Fév 2018
No. Why do you even think it would make sense? It essentially says what pixels to consider when doing a morphological operation. How can you consider the pixel a fractional amount? Like in dilation, you look at some pixels and take the max in a window. Let's say the window is a 3x3 window. You look at all 9 pixels and take the max of the 9 pixels. What would you take for the max if your structuring element was 0.7 in the corners instead of 1? If you just want to multiply your window by the image, then you should be using the conv2() function, not a morphological operation that uses a structuring element.
I'm not even sure why you consider that thresholding.
Perhaps you want fspecial() and/or conv2, or imfilter().

Murat Kocaman
Murat Kocaman le 26 Fév 2018
Modifié(e) : Murat Kocaman le 26 Fév 2018
% Thresholding
% Select Red component
level=graythresh(R);
binary=im2bw(R,level);
figure,imshow(binary)
title('Thresholded Image','FontSize',fontSize);
% Use Morphological Operations
erosion=imerode(binary,strel('disk',9));
figure,imshow(erosion)
title('Eroded Image','FontSize',fontSize);
% Use Watershed segmentation
D = bwdist(erosion);
figure
imshow(D,[],'InitialMagnification','fit')
title('Distance transform of ~bw')
D = -D;
D(~erosion) = -Inf;
L = watershed(D);
Lrgb = label2rgb(L,'jet',[.5 .5 .5]);
figure
imshow(Lrgb,'InitialMagnification','fit')
title('Watershed transform of D')
figure,imshow(imfuse(erosion,Lrgb))
axis([])
bw2 = ~bwareaopen(~erosion, 1);
imshow(bw2)
D = -bwdist(~erosion);
figure,imshow(D,[])
Ld = watershed(~D);
figure,imshow(label2rgb(Ld))
bw2 = erosion;
bw2(Ld == 0) = 0;
mask = imextendedmin(D,2);
D2 = imimposemin(D,mask);
Ld2 = watershed(D2);
bw3 = erosion;
bw3(Ld2 == 0) = 0;
figure,imshow(erosion);
title('Watershed Segmentation','FontSize',fontSize)
My code is above. What I want to do is to eliminate number 4 and 11 and to add new counts to the arrows.
  2 commentaires
Image Analyst
Image Analyst le 26 Fév 2018
Since everything looks like it should be in predefined positions, like you're using a jig to position your sample, why don't you just use a template with predefined regions? Just create a binary mask with white where you want the blobs to be and black elsewhere. Or, if you want each number to be in a known location, you can label it by creating a gray scale image where each blob has an integer with its label as the gray level.
Murat Kocaman
Murat Kocaman le 27 Fév 2018
Thanks but it is not a standard part. It changes depends on the product size and objects are not at the same position but my question was regarding the this image. This image was taken when the part works. Normally, all the objects at the numbers are available with the same light properties. I can not count the arrowed ones and I wonder why.

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by