Can strel / morh tools execute a custom operation on the kernel ?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi all,
I'd like to walk the perimeter of my 3D image in 2D xy planes.
I want my kernel to threshold the edge. So if kernel is say 4x4 pixels, then I want a rule, "any pixel < 0.5 = 0", where the image values are normalized to one.
This would save me a lot of time, rather than having to write code to do this myself.
TIA, wbg
0 Kommentare
Antworten (1)
Image Analyst
am 14 Jul. 2012
I don't know what you're saying. What does "walk the perimeter" mean? Why not just call bwboundaries on each 2D slice of your 3D image? And why are you using a kernel with an even number of pixels instead of an odd number? What are your pixel values? Are they in the 0-1 range? It appears that you don't have a uint8 image with pixels in the 0-255 range or even a 16 bit integer image.
I really don't know what this means: "any pixel < 0.5 = 0", where the image values are normalized to one.
But to set any pixel with a value less than 0.5 to 0 you do this:
array3D(array3D<0.5) = 0;
That will not change the class of the image. If it's a double, it will still be a double, not a binary (logical) image. If you want to normalize the image you can use regular scaling formulas, or try im2double(). But your "rule" seems to say that you will only do the test "any pixel < 0.5" where the image pixel value is 1, which totally doesn't make any sense. If it's 1, then it will never be less than 0.5.
Finally I don't know what it means when you say you want your kernel to threshold the edge. Thresholding is done by a line of code like
thresholdedImage = edgeImage < thresholdValue;
not by morphology (if that's what you meant by "morh"). And of course you have to have the edge image beforehand.
So I'd love to help but you're going to have to explain better what you want.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!