How can I find all values that is over and under the iso-value and then visualize them?
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Image Analyst
2022-10-5
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 个评论
Image Analyst
2022-10-5
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');
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Orange 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!