How to increase maximum figure size?

18 visualizaciones (últimos 30 días)
Markus Hosbach
Markus Hosbach el 6 de Sept. de 2016
Comentada: Markus Hosbach el 7 de Sept. de 2016
Hi everyone, I use MATLAB for image processing. After having done my calculations I would like to save the image. Since the image resolution is higher than my screen resolution I encouter problems while displaying or saving my image.
myimage=rand(600,1800);
figure();
imagesc(myimage);
axis tight;
set(gca, 'Visible', 'off');
set(gca, 'Position', [0 0 1 1]);
set(gcf, 'Position', [1 1 size(myimage, 1) size(myimage, 2)]);
pause(2);
get(gcf,'position')
The height seems to be limited by my screen resolution: 1920x1200. How can I increase the window size so that it fits my actual image size?
Thank you
  3 comentarios
Markus Hosbach
Markus Hosbach el 7 de Sept. de 2016
Editada: Markus Hosbach el 7 de Sept. de 2016
Imwrite would be a very nice solution. Is there any way to adjust the caxis within imwrite? I use a different colormap and I need to set the color limits. Something like:
caxis([0 0.5]);
imwrite(myimage,flipud(colormap(jet)),'myimage.png');
Adam
Adam el 7 de Sept. de 2016
Assuming your image is a 2d indexed image you can map it via the colourmap to produce a true RGB image for saving. I'll put that in an answer below.

Iniciar sesión para comentar.

Respuesta aceptada

Adam
Adam el 7 de Sept. de 2016
Editada: Adam el 7 de Sept. de 2016
myImage=rand(600,1800);
cmap = flipud( jet(256) );
myImageIndices = uint8( myImage * 255 ) + 1 % Note - this is because the colourmap by default is size 256. If you change the colourmap size then use int16 and change 255
rData = reshape( cmap( myImageIndices, 1 ), 600, 1800 );
gData = reshape( cmap( myImageIndices, 2 ), 600, 1800 );
bData = reshape( cmap( myImageIndices, 3 ), 600, 1800 );
rgbData = cat(3, rData, gData, bData );
imwrite( rgbData, 'myimage.png' )
That should map your data onto a colourmap and then save it. Obviously if I was doing this properly I would put it in a function (which I have done for my own usage) and not hard code the image sizes, etc, but you can change those as you see fit. You can also choose the size of colourmap you use if you don't want 256, but if you go higher then use a uint16 or int16 to store the image indices into the colourmap.
There may be quicker ways using builtin image processing toolbox functions, but I have never familiarised myself with those so have tended to write my own classes or functions to do this type of thing.
To deal with different caxis limits you would want to change this line:
myImageIndices = uint8( myImage * 255 ) + 1;
The 255 in here means it is mapping to the full range of the colourmap. If you change this number then your data will map to different values in the colourmap. e.g. if you changed it to 511 then you should get the equivalent of a [0 0.5] clims. This will work as is in the above case because the uint8 will clip. If you are using a smaller colourmap or a uint16 then you will need to manually clip the indices down to the maximimum range of the colourmap. Again there may be easier ways to do this. I have a class that does range mapping for me so it is just a one line call to map from any input range to any output range.
  1 comentario
Markus Hosbach
Markus Hosbach el 7 de Sept. de 2016
Thank you so much. It works like a charm.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Blue en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by