이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
hello.. i want to a simple gui that contain a plain space so that i can sign on that plain . then i also want to put a push button in that gui so that i can save the figure of my sign.
i try to use the code in http://www.mathworks.com/matlabcentral/fileexchange/7347 and it work perfectly. i actually want to place the figure of free draw into the gui...
my question is that possible for me to use the axes gui as the place where the plain figure to appear..? (sorry for my English)
can anyone help me..?
채택된 답변
Image Analyst
2013년 4월 28일
편집: Image Analyst
2013년 4월 28일
2 개 추천
Yes, it is. Go ahead and set the active axes with
axes(handles.axes2); % Assuming you want axes2 to be the one you draw in.
[x, y] = imfreehand().
Here's a standalone demo:
clc; % Clear command window.
clear; % Delete all variables.
close all; % Close all figure windows except those created by imtool.
imtool close all; % Close all figure windows created by imtool.
workspace; % Make sure the workspace panel is showing.
fontSize = 16;
% Read in a standard MATLAB gray scale demo image.
folder = fullfile(matlabroot, '\toolbox\images\imdemos');
baseFileName = 'cameraman.tif';
% 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.
fullFileName = baseFileName; % No path this time.
if ~exist(fullFileName, '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
grayImage = imread(fullFileName);
imshow(grayImage, []);
axis on;
title('Original Grayscale Image', 'FontSize', fontSize);
set(gcf, 'Position', get(0,'Screensize')); % Maximize figure.
message = sprintf('Sign your name.\nLeft click and hold to begin drawing.\nSimply lift the mouse button to finish');
uiwait(msgbox(message));
% User signs name here.
hFH = imfreehand();
% Get the xy coordinates of where they drew.
xy = hFH.getPosition
% get rid of imfreehand remnant.
delete(hFH);
% Overlay what they drew onto the image.
hold on; % Keep image, and direction of y axis.
xCoordinates = xy(:, 1);
yCoordinates = xy(:, 2);
plot(xCoordinates, yCoordinates, 'ro-', 'LineWidth', 2);
caption = sprintf('Original Grayscale Image.\nPoints may not lie on adjacent pixels, depends on your speed of drawing!', 'FontSize', fontSize);
title(caption, 'FontSize', fontSize);
% Ask user if they want to burn the line into the image.
promptMessage = sprintf('Do you want to burn the line into the image?');
titleBarCaption = 'Continue?';
button = questdlg(promptMessage, titleBarCaption, 'OK', 'Cancel', 'OK');
if strcmpi(button, 'Cancel')
return;
end
cla;
hold off;
for k = 1 : length(xCoordinates)
row = int32(yCoordinates(k));
column = int32(xCoordinates(k));
grayImage(row, column) = 255;
end
imshow(grayImage, []);
axis on;
caption = sprintf('Grayscale Image with Burned In Curve.\nPoints may not lie on adjacent pixels, depends on your speed of drawing!', 'FontSize', fontSize);
title(caption, 'FontSize', fontSize);
댓글 수: 5
armeen
2013년 4월 30일
i sorry sir... i am very new on this matlab..n i really don't get what u telling me..=(
ok let start over again...i actually want to create a simple program that can be use as signature input..the signature that need to be verify.. during review on the file exchange i got a new free hand drawing which the code is like this..:
%% sketch on the plain
function sketch(cmd)
if nargin == 0
cmd = 'init';
end
switch cmd
case 'init'
fig = figure('DoubleBuffer','on','back','off');
info.ax = axes('XLim',[0 1],'YLim',[0 1]);
axis off
info.drawing = [];
info.x = [];
info.y = [];
info.t =[];
set(fig,'UserData',info,...
'WindowButtonDownFcn',[mfilename,' down'])
case 'down'
tic;
myname = mfilename;
fig = gcbf;
info = get(fig,'UserData');
curpos = get(info.ax,'CurrentPoint');
info.x = curpos(1,1);
info.y = curpos(1,2);
info.drawing = line(info.x,info.y,'Color','k');
set(fig,'UserData',info,...
'WindowButtonMotionFcn',[myname,' move'],...
'WindowButtonUpFcn',[myname,' up'])
case 'move'
fig = gcbf;
info = get(fig,'UserData');
curpos = get(info.ax,'CurrentPoint');
info.e = curpos(1,1); %to read x coordinate in single
info.f = curpos(1,2); %to read y coordinate in single
info.x = [info.x;curpos(1,1)];
info.y = [info.y;curpos(1,2)];
set(info.drawing,'xData',info.x,'yData',info.y)
set(fig,'UserData',info);
case 'up'
toc;
fig = gcbf;
set(fig,'WindowButtonMotionFcn','',...
'WindowButtonUpFcn','')
drawnow; pause(.1)
info = get(gcf, 'Userdata')
end
i run with matlab R2007b...if u run this code u will get a plain figure where u can draw freely on that figure.. my problem now is i don't know how to place this code into the gui so that i can freely sign on gui.
and if possible, i also want to place a push button in the gui so that i can save the sign figure as a image in a folder.
hmm...hope u get what my problem..
regard
Image Analyst
2013년 4월 30일
Your code essentially does nothing, so I'm not at all surprised it doesn't work. However, I'm still baffled as to why my code that lets you draw your signature onto an image, and save the image, is not what you want.
armeen
2013년 4월 30일
hmmm....i really don't know...its already 6.30am here... i successfully run my code...
but when i try to directly run ur standalone demo..matlab came with this error...
??? Error using ==> iptchecknargin at 57 Function IMFREEHAND expected at least 1 input argument but was called instead with 0 input arguments.
Error in ==> roiParseInputs at 29 iptchecknargin(low,high,nargin_client,client_name);
Error in ==> imfreehand at 166 [commonArgs,specificArgs] = roiParseInputs(1,5,varargin,mfilename,{'Closed'});
Error in ==> Untitled at 31 hFH = imfreehand();
Image Analyst
2013년 5월 1일
It doesn't require any arguments, as the help and examples in the help show. Though you can call it passing gca as the input if you want. put
whos imfreehand
right before to see what it says. Maybe you have a second one somewhere that's overwriting it.
armeen
2013년 5월 11일
i had try run your code on matlab 2012...its working...tq fo ur help....=)
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Convert Image Type에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
