how to saving image of quadtree from axes

2 views (last 30 days)
Dear all,
I have a problem in saving quadtree image from gui axes.
I've written this code to calculate quadtree decomposition
qt = qtdecomp(im,t);
blocks = repmat(uint8(0),size(qt));
for dim = [512 256 128 64 32 16 8 4 2 1];
numblocks = length(find(qt==dim));
if (numblocks > 0)
values = repmat(uint8(1),[dim dim numblocks]);
values(2:dim,2:dim,:) = 0;
blocks = qtsetblk(blocks,qt,dim,values);
end
end
blocks(end,1:end) = 1;
blocks(1:end,end) = 1;
hold on;
axes(handles.quadtree); % axes for displaying quadtree image in gui Matlab
imshow(blocks,[]);
Then, i wanna save the image by calling this function
function save_Callback(hObject, eventdata, handles)
% hObject handle to simpan (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
ImQuadtree = getimage(handles.quadtree);% getting image from quadtree axes
[nm_file,nm_dir] = uiputfile({'*.jpg';'*.bmp';'*.png';'*.tif';'*.*'},'Saving Quadtree Image');
if isequal(nm_file,[])
msgbox('The Image is not Stored!','Warning','warn');
elseif isequal(ImQuadtree,[])
msgbox('There is no image to stored!','Warning','warn');
else
imwrite(ImQuadtree,strcat(nm_dir,nm_file));
msgbox('Quadtree Image Successfully Stored','Save','help');
end
The problem is when the image is successfully saved, the image result is a black image. There is no block on these image. So, how i can save the image block??

Accepted Answer

Chandra Kurniawan
Chandra Kurniawan on 29 Feb 2012
Hi, Elsya
please try to add this line
ImQuadtree = 255*ImQuadtree;
after line :
ImQuadtree = getimage(handles.quadtree);% getting image from quadtree axes
in your 'save_Callback'
I hope this works

More Answers (0)

Community Treasure Hunt

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

Start Hunting!