Matlab basics: basics of image

--

%% learning objectives: learning the basics of image
 
 %% to enhance the image by dithering the color contrast 
Clear All; 
Close All; 
the I = imread ( ' cameraman.tif ' );% read gradation image 
BW = DITHER (the I );% to enhance the contrast of the image by converting the color to binary image shake 
the subplot ( . 1 , 2 , . 1 );% plurality of images displayed in the same window, subplot (m, n, p ). 
imshow (the I); 
the subplot ( . 1 , 2 , 2 ); 
imshow (BW);
 
 %% acquiring image information 
Clear All; 
Close All; 
info = imfinfo ( ' trees.tif ' , 'TIF ' );% acquiring image information 
DISP (info); % outputs image information
 
 %% changing the image format 
Clear All; 
Close All; 
RGB = imread ( ' trees.tif ' , ' TIF ' );% reads an RGB image 
imwrite (the RGB, ' Mytrees.png ' , ' png ' );% converting the image format is png tif format 
tupian = imread ( ' Mytrees.png ' ); 
Figure; 
imshow (tupian);
 
 %% read certain image frame 
Clear All; 
Close All; 
I1 = imread (' Mri.tif ' , . 5 );% reads the first five 
I20 = imread ( ' mri.tif ' , 25 ); 
Figure; 
the subplot ( . 1 , 2 , . 1 ); 
imshow (I1); 
the subplot ( . 1 , 2 , 2 ); 
imshow (I20);
 
 %% Which mri.tif see the image position
 
 %% simultaneously displaying multiple images 
Clear All; 
Close All; 
MRI = uint8 (zeros ( 128 , 128 , . 1 , 25 ));
 for= I . 1 : 25   % 25 frame 
    [MRI (:,:,:, I), Map] = imread ( ' mri.tif ' , I); 
End 
Montage (MRI, Map); % simultaneously displaying multiple images
 
 %% the multi-frame image into the film 
Clear All; 
Close All; 
MRI = uint8 (zeros ( 128 , 128 , . 1 , 25 ));
 for I = . 1 : 25 
    [MRI (:,:,:, I), Map] = imread ( ' mri.tif ' , I); 
End 
MOV = immovie (MRI, Map);%  convert the image to an animation
implay (MOV); % animation is displayed
 
 %% image if the sum is greater than 255 it is set to 255 
Clear All; 
Close All; 
the I = imread ( ' rice.png ' ); 
J = imread ( ' cameraman.tif ' ); 
K = imadd (the I, J, ' UInt16 ' ); 
imshow (K, []);
 
 %% image subtraction, less than 0 is set to 0, 0 to 255 minus a constant darker 
Clear All; 
Close All; 
the I = imread ( ' cameraman.tif ' ); 
J = imsubtract (the I, 90 );% subtracting greater minus 90, an image darker (black table Well 0) 
imshow (J);
 
 %%Multiplying the image 
Clear All; 
Close All; 
the I = imread ( ' cameraman.tif ' , ' TIF ' ); 
J = immultiply (the I, 0.6 );% by of 0. The . 6 (less than 1), darken 
the subplot ( 121 ); 
imshow (the I); 
the subplot ( 122 ); 
imshow (J);
 
 %% image to the same division dimension 
Clear all; 
Close all; 
X- = uint8 ([ 222  50  21 is ; 56 is  77  89 ]); X-and the Y% are 2 * 3 matrix of 
the Y = uint8 ([ 66  66  66; 66  66  66 ]); 
the Z = imdivide (X-, the Y); X-% / the Y 
DISP (the Z);
 
 %% absolute difference of two images 
Clear All; 
Close All; 
the I = imread ( ' cameraman.tif ' , ' TIF ' ); 
J = uint8 (filter2 the (fspecial ( ' Gaussian ' ), the I));% image is filtered 
K = imabsdiff (the I, J);% acquires the difference filtered image and the previous image of 
the subplot ( 121 ); 
imshow (the I); 
the subplot ( 122 ); 
imshow (K, []); % add [] to display clear
 
%% fspecial: for establishing a predefined filter operator or produce a predetermined filter

Original: https: //blog.csdn.net/KimLK/article/details/78064384

 

--

Guess you like

Origin www.cnblogs.com/Ph-one/p/11516811.html