How can I find all values that is over and under the iso-value and then visualize them?
1 view (last 30 days)
Show older comments
Trying some new things and wanted to do something like this
I've been trying for some time now but the closest i can get is the red circle. I figured I could use find() to find these values and then scatter() to visualize it. But I get errors that x and y is not the same length.
Here's the code:
x=linspace(-2,2,1000);
y=x';
z=exp(-(x.^2+y.^2));
a = find(z>0.2)
hold on
s = contour(x,y,z,[0.2 0.2], 'r')
scatter(z,a)
0 Comments
Answers (1)
Image Analyst
on 5 Oct 2022
Try this:
x=linspace(-2,2,1000);
y=x';
z=exp(-(x.^2+y.^2));
subplot(2, 1, 1);
imshow(z, []);
colorbar
% Find elements with z > 0.2
mask = z > 0.2;
% Overlay it on the image
subplot(2, 1, 2);
rgbImage = imoverlay(z, mask, 'r');
imshow(rgbImage);
% Get boundaries and display over the original image.
subplot(2, 1, 1);
hold on;
b = bwboundaries(mask);
visboundaries(b);
2 Comments
Image Analyst
on 5 Oct 2022
But you have far too many points. You have a thousand x locations and a thousand y locations, so that's a million points. If you plotted them all as dots, they would be so close together that it would look essentially like an image. If you want far, far fewer points, like 30, you can do this:
x=linspace(-2,2,30);
y=x';
[X, Y] = meshgrid(x, y)
X = X(:); % Turn into a column vector.
Y = Y(:); % Turn into a column vector.
z=exp(-(X .^ 2 + Y .^ 2));
% subplot(2, 1, 1);
scatter(X, Y);
% colorbar
% Find elements with z > 0.2
Z = reshape(z, length(x), length(y))
mask = Z > 0.2;
% Overlay it on the image
hold on;
scatter(X(mask), Y(mask), 'r', 'filled');
See Also
Categories
Find more on Orange in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!