given a contour returned by contourf,how to display the pixel values within a region
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
So,lets say I run contourf on an image ,and I get the contour for a particular level
say I is the image and level is [55,55].
Then running contourf(I,level) gives me the contour for level 55.
Now I would like to observe the pixel values within a certain region just as imtool does,is there a way for doing this?
Any help will be appreciated.
4 comentarios
Respuestas (1)
DGM
el 29 de Jul. de 2021
Why are you trying to get the pixel value of a contour map? The pixel values of the contour map don't tell you anything about the image -- the shape of the contour does. What's worse is you're looking at the pixel values in a map that looks like it's been damaged by saving it as a JPG. This is meaningless information.
This is one attempt:
testpict = im2uint8(mat2gray(peaks(500))); % make a test image
imshow(im2double(testpict)); hold on % draw image
contour(testpict,[55,55]); % draw contour map over image
The reason that the image is cast as double in the imshow() call is so that the pixel values are comparable to those used by contour(); otherwise, the contour lines won't be visible. Can the image be displayed in uint8 format with the contour overlay so that the datatip values are in uint8 range? I don't know. Maybe.
You can also just avoid the ambiguity of using a single-level contour map and just select a specific region and mask it off explicitly.
m = testpict <= 55;
maskedpict = im2uint8(im2double(testpict).*m);
imshow(maskedpict);
Either way, you can get the values of the image pixels using impixelinfo() or a datatip, as has been suggested already.
impixelinfo % mouse over for current pixel coordinates and value
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!