Redrawing on a UIpanel
2 views (last 30 days)
Show older comments
Hi.
I am wanting to rescale a montaged image I have created on a uipanel. i.e change the grayscale scaling (globally) and redraw it. My typical montage is created by reading in image files, resizeing and drawing on a uipanel using subplot and position vector format, using two for loops for x & y.
The montage is created by the 1st image being at the top left (labelled 1 in the montage) and the last being last being the bottom right (labelled 260), both highlighted in yellow here.

Within this loop, I assign each image i read from file (resized to thumbnail size) to a cell array:
allImgs{x1,y1} = IM1 ;
Outside the loops I then do:
montageImg = cell2mat(allImgs);
setappdata(0,'mtg',montageImg); % set global for later use
Inside a seperate button callback (for rescaling) I recall the saved montaged image.
montageImg=getappdata(0,'mtg');
Then rescale using values from edit boxes:
mlo=str2num(get(handles.editMLow,'String'));
mhi=str2num(get(handles.editMHi,'String'));
if mlo>mhi
mlo=0;
end
Delete whats currently displayed on the uipanel
delete(get(handles.uipanelM,'Children'))
drawnow
guidata(hObject, handles);
Now for the redrawing (this is where my problem is)
I get the handle of the uipanel
hp = handles.uipanelM;
and I want to use the following to rescale and redraw on the now blank uipanel.
*positionVector = [x, y, width, height]*
h=subplot('Position',positionVector,'Parent',hp); %to enable deleting use handles
imshow(montageImg,[mlo mhi]);
colormap(jet);
It appears when I try and calculate the new position vector of this "composite image" its not placing the image exactly int he same location and size as the original one.
For the x & y values, I use the x from the 1st thumbnail and the y from the last thumbnail (as these positions are always from the bottom left). So if First is the position vector of the thumnail 1 and last is the thumbnail shown here as 260
new position vector = [First(1), Last(2), width, height]
the width I take as the difference in the x's plus 1 thumnail width, so
width = Last(1)-First(1)+thumbnailwidth
and the height similary as:
height = First(1)-First(2)+thumnailheight
But its not mimicing the original shape when I redraw.
I can't see my obvious mistake Jason
5 Comments
Geoff Hayes
on 10 Nov 2014
Do the height and width values make sense? When the montage is drawn using these parameters, where does it fall short - in the height or width, or does it's upper left corner not start where the first subplot started?
Answers (0)
See Also
Categories
Find more on Convert Image Type in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!