save large image/figure
Show older comments
I have a large mxn (~300,000 x 75) element matrix that I would like to save as an image or pdf without any compression. I'm currently using imagesc() to display. I've used the print function to set my own resolution but I'm having difficulty achieving the desired result. The image is a large time series that I would like to save in such a way that I may zoom in over a region, and transmit the complete series to others without any losses. Is there a simple method to save large , essentially banner sized, images / figures?
Accepted Answer
More Answers (2)
Ingrid
on 19 May 2015
0 votes
I always use the export_fig figure for saving images since this doesn't crop the figure so you might want to look at this?
8 Comments
Ingrid
on 21 May 2015
I think you could have solved this by
figure('Position',[values of sizes required],'Visible','off')
but good to see that the other solution works.
Keyes34
on 30 Jun 2015
What do you mean by [value of sizes required]? Could you give an example of the input parameters?
Image Analyst
on 30 Jun 2015
It's x,y,width,height. So [0, 5., 1, .5] would be the top half of the screen, and [.5,0,.5,1] would be the right half of the screen. And [0, 0, .75, .5] would be a figure in the bottom half of the screen but going from the left edge to 3/4 of the way across the screen.
I keep getting a 2x2 8 bit image of grey.
RGBImage = imread(file);
figure('Position', [0 0 1 1], 'Visible','off'), RGBImage;
filename = sprintf('ROI_%s.bmp', Img{imageCount});
export_fig(filename, '-a2')
What am I doing wrong?
Image Analyst
on 30 Jun 2015
figure just brings up an empty figure. You never displayed anything with imshow() so the figure is blank. Then you do RGBImage, which does absolutely nothing. Then you create a filename, which is a string, and save the current figure, which is blank. Use imshow(RGBImage) and see if that fixes it.
RGBImage = imread(file);
% Display figure with image in an axes.
imshow(RGBImage);
% Size the figure to full screen.
figure('Position', [0 0 1 1], Visible','off');
filename = sprintf('ROI_%s.bmp', Img{imageCount});
export_fig(filename, '-a2')
I don't know what the cell array Img contains. Hopefully it's a string or else you're in trouble with that sprintf() statement.
Yeah, that's what I tried before. Just tried it again, same result; 2x2 8 bit image of grey. Not a problem with the Img cell array, no errors.
I can display the image, but when the image is saved I get that 2x2 gray thing. If I remove
figure('Position', [0 0 1 1], 'Visible','off');
Then the image is properly saved, just that I have the same problem as the OP.
Image Analyst
on 30 Jun 2015
Well obviously if you set Visible to off, the figure will be not visible and so what is there for export_fig() to save???
This works:
RGBImage = imread('peppers.png');
% Display figure with image in an axes.
imshow(RGBImage);
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Get rid of tool bar and pulldown menus that are along top of figure.
set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% filename = sprintf('ROI_%s.bmp', Img{imageCount})
% export_fig(filename, '-a2')
If the image is only 75 pixels high and 300 thousand wide, then it will show up on the screen as just a line because of the extreme aspect ratio. Why don't you just save it with imwrite()? I mean, there's no way you could put any annotation on that image anyway, and saving annotation is the main advantage export_fig() has over imwrite().
Oh. I see. Well then. Thought the guy's suggestion above would work.
To be honest, export_fig was mainly for this part of my code. Contour lines don't appear in imwrite, but they do in export_fig.
figure,imshow(RGBImage); hold on; %Hold for contour lines.
contour(Marked_ROI,[0 0],'b','LineWidth',2); %hold off;tried here b4
%Marked_ROI is a binary image.
filename = sprintf('ROI_%s.bmp', Img{imageCount});
imwrite(RGBImage, filename);
hold off;
Categories
Find more on Images in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!