Homework Solution: A grayscale image is essentially a matrix composed of brightness values for each pixel. C…

    A grayscale image is essentially a matrix composed of brightness values for each pixel. Commonly, there are 8-bit and 16-bit image. Look up binary number if you are not familiar with how bits work. Following problem uses 8-bit grayscale image. In other word, the value in each element of the matrix is an integer ranging [0, 256]. Type the following code in your script to load pre-installed MATLAB demo picture which is a 128 x 128 grayscale image: I=imread(‘mri.tif’); %transverse MRI scan of a human head figure imshow(I) Apply following matrix operations on the image ‘I’ to see what they do on the image. Hint: convert ‘I’ into data type doubles before any matrix computation. Then use function uint8 to coerce data type back to 8-bit to generate image using imshow. (4 points) • Make 128 by 128 matrix ‘N’ whose elements are all 255. Subtract image ‘I’ from it. Note 255 here is “one minus maximum pixel value”. • Make 128 by 128 reverse identity matrix ‘E’ (1’s go from top right to bottom left and everything else 0). Use for-loop matrix computation from part 1 to multiply ‘E’ to ‘I’. Order of multiplication matters. •Use for-loop to do element by element multiplication of image ‘I’ and ‘E’. Don’t use MATLAB built-in syntax ‘I.*E’. Order of multiplication doesn’t’ matter. Generate a figure containing 1 original image and 3 processed images. Use subplot and imshow function.

    Expert Answer

     
    I=imread('mri.tif'); % read Image imshow(I); % display original image

    A grayscale likeness is essentially a matrix secure of lucidity computes restraint each pixel. Commonly, there are 8-bit and 16-bit likeness. Look up binary calculate if you are not attributable attributable attributable accustomed with how bits performance. Aftercited height truths 8-bit grayscale likeness. In other account, the compute in each atom of the matrix is an integer ranging [0, 256]. Cast the aftercited legislation in your script to enjoin pre-installed MATLAB demo draw which is a 128 x 128 grayscale likeness: I=imread(‘mri.tif’); %transverse MRI review of a ethnical division cast imshow(I) Apply aftercited matrix operations on the likeness ‘I’ to look what they do on the likeness. Hint: change ‘I’ into basis cast doubles precedently any matrix deduction. Then truth business uint8 to compel basis cast tail to 8-bit to beacquire likeness using imshow. (4 points)

    • Make 128 by 128 matrix ‘N’ whose atoms are entire 255. Subtract likeness ‘I’ from it. Not attributable attributablee 255 here is “one minus climax pixel compute”.

    • Make 128 by 128 end unity matrix ‘E’ (1’s go from head fair to deep left and everything else 0). Truth restraint-loop matrix deduction from segregate 1 to enrich ‘E’ to ‘I’. Order of multitude substances.

    •Truth restraint-loop to do atom by atom multitude of likeness ‘I’ and ‘E’. Don’t truth MATLAB built-in syntax ‘I.*E’. Order of multitude doesn’t’ substance. Beacquire a cast containing 1 pristine likeness and 3 processed likenesss. Truth subplot and imshow business.

    Expert Solution

     

    I=imread(‘mri.tif’); % unravel Likeness

    imshow(I); % expose pristine likeness
    I=double(I); % conver to double
    N=255*ones(128,128); % originate a matix N of greatness 128×128 of 1s
    Inew=N-I; % Originate a novel proccessed likeness Inovel by subtacting I from N
    E=eye(128,128); % originate a unity matrix of greatness 128×128
    E=flip(E); % flip the unity matrix E to acquire the required matrix E 1’s goes to head fair
    Iei=zeros(128,128); %Originate a matrix Iei of 0’s to abundance the emanation of ‘I’ and ‘E’
    Iie=[];  %Originate a matrix ‘Iie’ to abundance the emanation of ‘E’ and ‘I’

    %——- restraint loop restraint matrix multitude of ‘E’ and ‘I’
    restraint i=1:length(I)
    restraint j=1:length(I)
    restraint k=1:length(I)
    Iei(i,j)=Iei(i,j)+E(i,k)*I(k,j);
    end
    end
    end

    %———Multitude of ‘E’ and ‘I’ purpose here————————-

    %———- Restraint loop restraint multplication of ‘I’ and ‘e’ atom by atom—–

    restraint i=1:length(I)
    restraint j=1:length(I)
    Iie(i,j)=I(i,j)*E(i,j);
    end
    end

    %———— multitude purpose here————-

    %—-expose the likenesss—————————-
    subplot(2,2,1)
    imshow(I,[1 255]); %——[1 255]——– change tail the computes of ‘I’ in insult restraint 1 to 255 restraint expose
    subplot(2,2,2)
    imshow(Iei,[1 255]); %——[1 255]——– change tail the computes of ‘Iei’ in insult restraint 1 to 255 restraint expose
    subplot(2,2,3)
    imshow(Iie,[1 255]); %——[1 255]——– change tail the computes of ‘Iie’ in insult restraint 1 to 255 restraint expose