Reading and displaying Matlab image

%%------------------------------------------- Matlab image reading fetch and display ----------------------------

%-------------------head File---------------------------- -

clc ; % clear screen

clear ; % delete all variables

close all ; % close all open pictures

%-------------------Display a picture------------------------

P = imread('1.jpg') ; %The function of reading the image, the address of the image is in the brackets

imshow(P) ; %imshow displays the picture according to the original proportion

%------------------Show Multiple Images--------------------------- -

for i = 1 : 5 % loop

% Note that [ ] is added to ensure that this is a complete sentence. num2str(i) converts i from a number to a character form

A = imread( [ 'D:\MATLAB_R2016a\MyTrainningSet\' , num2str(i) , '.jpg'] ) ;

%When only one image is displayed in the program, just imshow directly. Then when you need to display multiple pictures at the same time, you need to use figure to create a new window

figure ; imshow(A) ;

end

%------------------------Graph window split---------------------- ------

% If you want to output multiple pictures on one screen, you need to use subplot to split the window

B1 = imread('1.jpg') ;

B2 = imread('2.jpg') ;

subplot( 2, 2, 1) ; % Divide the window into 2 rows and 2 columns with a total of 4 grids, and place the picture in the first grid

imshow( B1 ) ;

title('Figure 1') ; %Add a title

subplot(3, 3, 6) ; % Divide the window into 3 rows and 3 columns with a total of 9 grids, and put the picture in the 6th grid

imshow(B2) ;

title('Figure 2') ;

Guess you like

Origin blog.csdn.net/starryskyzl/article/details/129078901