Matlab imshow function border tight not working under small size image
Ältere Kommentare anzeigen
By default, when imshow displays an image in a figure, it surrounds the image with a gray border. You can change this default and suppress the border using the 'border' parameter.
But, I recently found that border tight will stop working when the matrix is smaller than approximately 125-130 thresholding
Please try these two Matlab command and you will see the difference
imshow(rand(130,130),'Border','tight') % works! no grey boundary at all
imshow(rand(120,120),'Border','tight') % not working! grey boundary appears

I carefully read the doc and found the sentence below When set to ‘tight', the figure window does not include any space around the image in the figure. If the image is very small or if the figure contains other objects besides an image and its axes, imshow might use a border regardless of how this parameter is set.
That is very disappointing. What I am trying to do is to capture image after imshow and store it to the matrix using command like
f=getframe(gcf);
resultMatr=f.cdata;
so any border will influence the result.
Any solution for that?
Antworten (1)
Jihang Wang
am 4 Mär. 2015
Bearbeitet: Jihang Wang
am 4 Mär. 2015
2 Kommentare
Cg Gc
am 9 Jan. 2019
I know this is a little odd, but can you provide an example of how to use your function? I am trying to group a few images together and I really would like to remove the border, but I keep receiving an error message because I don't have enough input arguments. I am not sure what that means. An example would be lovely.
Thank you.
Walter Roberson
am 9 Jan. 2019
Example of use:
img = imread('cameraman.tif');
outsize = 100;
outputimg = removeBorder(img, outsize);
Kategorien
Mehr zu Convert Image Type finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!