Issues concerning ginput() and true image size
Mostrar comentarios más antiguos
I've been working on a method for a user to specify a custom ROI for data analysis. This consists of the use of ginput(4) to select the four vertices, and a few image processing steps to basically turn those coordinates into a binary mask of the polygon's inner pixels. I am quite close to finalizing my solution, and here is the fucntion below (Note that it's being used in GUIDE):
function [x,y,indices] = PolygonROI(hObject, eventdata, handles)
ROI = figure;
imagesc(handles.meanim)
truesize(ROI,size(handles.meanim))
[x,y] = ginput(4);
x = round(x); y = round(y);
imagesc(handles.meanim*0)
truesize(ROI,size(handles.meanim))
line([x;x(1)],[y;y(1)],'Color',[1 1 1])
dat = getframe;
im = logical(round(rgb2gray(dat.cdata)/256));
indices = imfill(im,'holes');
guidata(hObject,handles);
Here's my final issue: As you can see, I use the command truesize() to prevent my getframe() from displaying the data in the wrong scaling. My input image is 128x128, and all image plots seem to plot at the wrong scale unless I do this. My final binary output image is close, but not exactly right! It comes out about 1-2 pixels off my target size every time (130x129, etc.). How can I improve this code? Am I making this harder than it needs to be?
Thanks for the help.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Data Exploration en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!