フィルターのクリア

How can I create a surface with points distributed randomly ?

16 ビュー (過去 30 日間)
Mallouli Marwa
Mallouli Marwa 2019 年 4 月 6 日
編集済み: Image Analyst 2019 年 4 月 10 日
Hi
How can I create a surface with points distributed randomly like the attached file.
Best regards
  2 件のコメント
Mallouli Marwa
Mallouli Marwa 2019 年 4 月 6 日
I search how can I create a plane with points not a 3d curve.

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2019 年 4 月 6 日
N = 25;
x = rand(1,N) * 150; %wider than it is tall
y = rand(1,N) * 50;
pointsize = 20;
scatter(x, y, pointsize, 'filled')

その他の回答 (1 件)

Image Analyst
Image Analyst 2019 年 4 月 6 日
Try scatteredInterpolant()
  2 件のコメント
Mallouli Marwa
Mallouli Marwa 2019 年 4 月 6 日
How can I simulate it ?
Image Analyst
Image Analyst 2019 年 4 月 10 日
編集済み: Image Analyst 2019 年 4 月 10 日
Try this demo:
% Demo to show how scatteredInterpolant works to create a complete image out of arbitrarily placed sample points.
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
numTrainingPoints = 50; % Number of points we'll have to try to estimate our image everywhere.
imageWidth = 300;
% Create sample surface
z = peaks(imageWidth);
[rows, columns] = size(z);
% Plot it as a flat image.
subplot(2, 2, 1);
imshow(z, []);
title('Original Image with Training Points in Red', 'FontSize', fontSize, 'Interpreter', 'None');
% Show it as a perspective 3-D-ish image.
subplot(2, 2, 3);
surf(z, 'EdgeColor', 'none');
title('Original Surface', 'FontSize', fontSize, 'Interpreter', 'None');
% Create sample coordinates
xi = imageWidth * rand(numTrainingPoints, 1);
yi = imageWidth * rand(numTrainingPoints, 1);
% Plot these over the image
subplot(2, 2, 1);
hold on;
plot(xi, yi, 'r.', 'MarkerSize', 15);
% Get z values. For this demo, let's get them from the peaks image.
% Then we'll try to recreate the peaks shape from the few points in x and y.
for k = 1 : length(xi)
zi(k) = z(ceil(yi(k)), ceil(xi(k)));
end
zi = zi'; % Make zi a column vector like scatteredInterpolant requires.
%================================ MAIN PART RIGHT HERE ==============================================
% Make the scattered interpolant.
F = scatteredInterpolant(xi, yi, zi)
% Get a grid of points at every pixel location in the RGB image.
[xGrid, yGrid] = meshgrid(1:columns, 1:rows);
xq = xGrid(:);
yq = yGrid(:);
% Evaluate the interpolant at query locations (xq,yq).
vq = F(xq, yq);
fittedImage = reshape(vq, rows, columns);
%================================ END OF MAIN PART ==============================================
% Plot it as a flat image.
subplot(2, 2, 2);
imshow(fittedImage, []);
title('Interpolated Image with Training Points in Red', 'FontSize', fontSize, 'Interpreter', 'None');
drawnow;
% Plot the training points over the image.
hold on;
plot(xi, yi, 'r.', 'MarkerSize', 15);
% Show it as a perspective 3-D-ish image.
subplot(2, 2, 4);
surf(fittedImage, 'EdgeColor', 'none');
title('Interpolated Surface', 'FontSize', fontSize, 'Interpreter', 'None');
%------------------------------------------------------------------------------
% Set up figure properties:
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0.04, 1, 0.96]);
% Get rid of tool bar and pulldown menus that are along top of figure.
% set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
00_Screenshot.png

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeVisual Exploration についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by