フィルターのクリア

A problem in the loop

1 回表示 (過去 30 日間)
Nada Kadhim
Nada Kadhim 2015 年 4 月 17 日
コメント済み: Nada Kadhim 2015 年 4 月 19 日
Hi,
Please I want to draw a patch from four corner points of each building in the image. However, I do not know how can I create a loop for this purpose.
I posted my codes and I will highly appreciate any help may I get.
aa = imread('test_8bit_vis.tif');
figure, image(aa)
[x, y] = ginput
save My_Coordinates.mat x y
hold on
plot(x,y,'xw');
for ii = 1:length(x-1)
ind = x(1:4) + 4 * (ii-1);
patch(x(ind), y(ind),'yellow');
end

採用された回答

Image Analyst
Image Analyst 2015 年 4 月 19 日
See my code for doing it:
% Display something so we can draw on it.
folder = fileparts(which('office_4.jpg')); % Determine where demo folder is (works with all versions).
baseFileName = 'office_4.jpg';
% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);
% Check if file exists.
if ~exist(fullFileName, 'file')
% File doesn't exist -- didn't find it there. Check the search path for it.
fullFileNameOnSearchPath = baseFileName; % No path this time.
if ~exist(fullFileNameOnSearchPath, 'file')
% Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist in the search path folders.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
rgbImage = imread(fullFileName);
imshow(rgbImage, []);
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
message = sprintf('Draw your polygon with left clicks.\nRight click the last point to finish it.');
uiwait(helpdlg(message));
loopCounter = 1;
while loopCounter < 30
% Let user draw the polygon.
[~, x, y] = roipolyold;
% Draw a yellow patch over the image.
patch(x, y,'yellow');
% Ask user if they want to continue.
promptMessage = sprintf('Do you want to Continue drawing patches,\nor Cancel to quit drawing?');
titleBarCaption = 'Continue?';
button = questdlg(promptMessage, titleBarCaption, 'Continue', 'Cancel', 'Continue');
if strcmpi(button, 'Cancel')
break;
end
loopCounter = loopCounter + 1;
end
It this meets the requirements, go ahead and please mark it Accepted.
  1 件のコメント
Nada Kadhim
Nada Kadhim 2015 年 4 月 19 日
Hi Image Analyst, Thank you very much for your help. Yours sincerely, Nada

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by