Delete Interval In Matlab Subtitle

How do I remove the white space between these images? I need to combine all these images without any space.


bot=imread('bot.jpeg'); for i= 1:25 subplot(5,5,i),imshow(bot); end 

enter image description here

+6
source share
3 answers

You need to specify the axes 'Position' property when you create them using subplot .

In addition, you need to adjust the proportions of the shape to fit the image so that all shapes fit without vertical or horizontal space.

If you show a different image in each subtitle, all images must have the same aspect ratio, otherwise they cannot be placed in a figure without empty spaces.

 bot = imread('peppers.png'); for i= 1:25 subplot('Position',[(mod(i-1,5))/5 1-(ceil(i/5))/5 1/5 1/5]) imshow(bot); %// or show a different image on each subplot end p = get(gcf,'Position'); k = [size(bot,2) size(bot,1)]/(size(bot,2)+size(bot,1)); set(gcf,'Position',[p(1) p(2) (p(3)+p(4)).*k]) %// adjust figure x and y size 

enter image description here

+7
source

The most canonical way is to look at this bla answer here . This response uses the function from the file exchange MATLAB to achieve the response. However, this requires learning a new function and playing with parameters.

If you want something to work immediately, instead of showing each subimage in a separate grid on the graph, I just create a new image that sums all these images together:

 bot_new = repmat(bot, [5 5]); imshow(bot_new); 

repmat takes a matrix and duplicates / stacks / tiles by itself for the number of rows and as many columns (or in any dimension) that you want. In this case, I decided to fold the image so that there were 5 rows and 5 columns. Then we will show the folded image along with imshow .

If we used an example image from MATLAB:

 bot = imread('onion.png'); 

If we run the above code, which splits the images together and shows the image, this is what we get:

enter image description here

+4
source

I copy the answer from mathworks:

For each subtitle, save its handle.

  h = subplot(2,3,1); 

Then set the "position" property for h as you like.

  p = get(h, 'pos'); 

This is a 4-element vector [left, bottom, width, height], which by default is in normalized coordinates (as a percentage of the curly window). For example, add 0.05 units (5% of the figure) to the width, do the following:

  p(3) = p(3) + 0.05; set(h, 'pos', p); 

The SUBPLOT command selects the standard values ​​for these parameters, but they can be whatever you want. You could put the axis anywhere in the shape you want, any size you want.

You can check this out: http://www.mathworks.com/matlabcentral/newsreader/view_thread/144116

+1
source

Source: https://habr.com/ru/post/982174/


All Articles