Memory Usage with Tiff whilst montaging

I have a bout 260 tiff images 94MB each), that I have been montaging. I have used the follwoign tor educe their size. I do shrink them as well so each is viewed at about 10%.
IM1 = impyramid(IM, 'reduce');
although I have a really fast PC (16GB ram), its slows down drastically and takes forever. Previously I was only montaging 50 image, not 260.
Are there anymore tips where I can reduce the memory usage. I do not need the full resolution of the tiffs as Im only looking for large scale variations. Thanks Jason

2 Kommentare

Geoff Hayes
Geoff Hayes am 31 Okt. 2014
Jason - it would be helpful to show more of your code especially that which is relevant to your problem. Do you read each image from file, one at a time, then reduce it, then do something else? You mention how you were previously montaging 50 images (which presumably was acceptable in terms of processing time).
Also, quantify what you mean by its slows down drastically and takes forever. Does that mean five minutes, fifty minutes, or ..?
Hi, I am using subplots with position vectors to create a 13x20 montage. I have the following in a loop:
positionVector = [os+x, y, width, height];
%subplot('Position',positionVector);
hp = handles.uipanelM;
h=subplot('Position',positionVector,'Parent',hp); %to enable deleting use handles
% update handle array
hSubplots = [hSubplots ; h]; %Concatenate
axis off;
hold off;
IM1 = impyramid(IM, 'reduce'); %downsample by 2 for montage (but not zoomed in image
lo=str2num(get(handles.editLow,'String'))
hi=str2num(get(handles.editHi,'String'))
Im_Scale(IM1,lo, hi);
%Calc mean and sd on an ROI of each image (before its reduced by Impyramid %Now calc SD on ROI
[xsize, ysize]=size(IM);
xc=ceil(xsize/2);
yc=ceil(ysize/2);
ROI=IM(xc-75:xc+75, yc-75:yc+75);
sd=std2(ROI(:));
mn=mean(ROI(:));
%Show on a seperate axes to montaged imgae, a view of the ROI
stdmap(y1,x1) = sd;
meanmap(y1,x1) = mn;
J = imadjust(ROI,stretchlim(ROI),[0 1]);
axes(handles.axes1)
cla(handles.axes1,'reset')
axis off;
imshow(J);
colormap(jet)
zoom on;
drawnow;
I also plot a graph of mean & SD against image number (but not shown code her)
When it starts it takes about 0.5-1 second to process each image (add to montaged image on UIPanel, perform basic stats on a ROI and show this ROI. After about 60 images, it had slowed down to about 1-1.5s per image. Once I get intot he 100's, its morelike 3-5 s per image, and at 200 its close to 5-10s.
For the montage, I don't need the full resolution, which is why I thought the IMPyramid would be useful, maybe I need to do it again or even downsample by other means? I would be keen to try out any suggestions from the experts!
Thanks Jason

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Image Analyst
Image Analyst am 1 Nov. 2014

0 Stimmen

The montage function always stitches images together at full resolution, so frequently you will run out of memory if you have more than a few images. I have a request in to the Mathworks for a option where you can subsample or specify an output size. You can submit a request for enhancement to the Mathworks and hopefully this will appear in a future release.

4 Kommentare

Jason
Jason am 1 Nov. 2014
Hi IA. I dont use the montage function, I created my own one using the position vector for subplot and calculating the x and y for each image.
Image Analyst
Image Analyst am 1 Nov. 2014
I don't see any reason for it to slow down. You are clearing the axes, and that is the usual culprit, so that's good. I don't see any other reason why it would slow down as the images go on. You might try imresize() instead of impyramid() and see if that helps reduce the time.
Geoff Hayes
Geoff Hayes am 1 Nov. 2014
I seem to recall there being a similar question about performance when you try to update dozens of subplots in a figure - the performance degrades as the code updates subsequent subplots, which is similar to the behaviour that Jason has observed. And if there are 13*20=260 of them, then that could explain the poor performance.
Image Analyst
Image Analyst am 1 Nov. 2014
Unless he needs axes (tick marks) and/or annotation (text, arrows, etc.) that is unique for each image, he might be better off just creating a big image canvass (a giant image almost the size of the screen) and just pasting small thumbnail images in using normal indexing methods. I attach a demo for that.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Images finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 31 Okt. 2014

Kommentiert:

am 1 Nov. 2014

Community Treasure Hunt

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

Start Hunting!

Translated by