Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Matlab code needed for: User-defined function: process_image.m The input argumen

ID: 3575191 • Letter: M

Question

Matlab code needed for:

User-defined function: process_image.m The input arguments of the function are: the image/2D-matrix to be processed and a processing matrix h that specifies the desired type of process (for a total of two input arguments). The process/operation can be mathematically described with the following equation:

where I in and I out denote the supplied input-image and processed output-image respectively. x,y,n1 and n2 are coordinates/indices. More specifically x and y are the pixel coordinates of the input and output images and n1 and n2 are the indices of the processing matrix h. Note that this algorithm can only be applied for x > n1 and y > n2 since subscript indices must be real positive integers. Thus, you will not be defining all the elements of Iout. Also to note is that h is of size N by N. Let the output argument of the function be I out.

(Matlab code needed for this equation as user defined function.

Thanks

(x,y) out N N I, (x -n

Explanation / Answer

function Iout = process_image(Iin, h)
Iin = imread(Iin)
for i=1:size(Iin, 1)
    for j=1:size(Iin, 2)
        result = 0;
        for n1=1:size(h, 1)
            for n2=1:size(h, 1)      
                if i>n1 && j>n2
                    result += h(n1,n2)*Iin(i-n1, j-n2);
                end
            end
        end
        Iout(i, j) = result;
    end
end
imwrite(Iout, 'output.jpg');