Write matlab code for Image btif read the image into workspa
Write matlab code for:
Image: \"b.tif\"
read the image into workspace using function imread
display the image using function imshow
convert the color image into grayscale using function rgb2gray
display the histogram of the grayscale version using function imhist
enlarge the grayscale image by four times using function imresize
crop the enlarged image to its original size using function imcrop
display the image size, average intensity, maximum and minimum intensity
save the image into a file named “output.jpg” using function imwrite
--
Within the program, use comment lines to describe how to execute the program to demonstrate the successful completion of the above actions.
Solution
A = imread(\'b.tif\'); % reading the image using imread
imshow(A); %diso=paying the image using imshow
A1 = rgb2gray(RGB); % converting to black and white
figure
imshow(A1) %displaying image
imhist(A) %diplaying histogram for the image that we read
A2 = imresize(A, 4); %resizing the image to 4 times
[A3, rect] = imcrop(A2); %cropping the image
[x,y,z] = size(A); %size of image
[maxVal,maxInd] = max(A(:)); % maximum intensity
[minVal,minInd] = min(A(:)); % minimum intensity
avgerage = (maxVal+minval)/2 % average intensity
imwrite(A2,\'output.jpg\') %writing image
