How can i replace this code to fast up?
Mostrar comentarios más antiguos
for i=1:500,
subplot(23,23,i);
x=vishid(:,i);
imagesc(reshape(x,imagesize));
colormap gray;
end
Here,vishid is 784*500 matrix, imagesize=28*28
2 comentarios
Geoff Hayes
el 5 de Ag. de 2014
Subha - the above code is trying to create 500 subplots within the figure, so it may take some time! :) Adding a drawnow command after the colormap gray line shows how the first 30-40 subplots get drawn relatively quickly, but over time, it takes longer and longer to add the newest subplot to the figure. Even just doing the above with something as simple as
for k=1:500
h = subplot(23,23,k);
set(gca,'XLim',[0 1]);
drawnow;
end
takes a long time (this was just to see if the bottleneck had to do with the reshape and imagesc - not the case).
Is there a need to show all 500 subplots on the same figure, or could you break it into two figures of 250?
subha
el 5 de Ag. de 2014
Respuestas (3)
Jan
el 5 de Ag. de 2014
1 voto
Do you really need 500 images with separate axes objects? You can draw 500 im ages in one axes, when wet the coordinates appropriately. This would be much faster.
3 comentarios
subha
el 5 de Ag. de 2014
Image Analyst
el 6 de Ag. de 2014
I totally agree. 500 subplots is absurd. Most of the space will be taken up be white space and you won't see the images.
Matt J
el 6 de Ag. de 2014
Whether it's worthwhile depends on how well you need to see the images. Thumbnail views have their uses.
Matt J
el 5 de Ag. de 2014
Making the figure invisible until all subplots have been established might help,
h=figure;
set(h,'Visible','off')
for i=1:500,
subplot(23,23,i);
x=vishid(:,i);
imagesc(reshape(x,imagesize));
colormap gray;
end
set(h,'Visible','on')
Image Analyst
el 6 de Ag. de 2014
0 votos
If you have enough memory, use the montage() function. Or else just use regular indexing. Are the images grayscale or color?
6 comentarios
subha
el 6 de Ag. de 2014
Image Analyst
el 6 de Ag. de 2014
OK. So did you try what I suggested? What happened?
subha
el 24 de Sept. de 2014
Image Analyst
el 25 de Sept. de 2014
Seems like a weird thing to do, but I did it. Run the mfile attached below the image. I'll say one thing, it creates some interesting animation as it scans along the columns. Here is the final image it ends up with:

Image Analyst
el 25 de Sept. de 2014
Does it do what you want? I thought it did what you said to do. If it does, please mark it "Accepted".
Categorías
Más información sobre Color and Styling en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!