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

please help me... I will give you full credit if you solve even half of it The c

ID: 3552070 • Letter: P

Question


please help me...

I will give you full credit if you solve even half of it

The color values for images in MATLAB are stored as a type called uint8. This format does not allow values below 0 or above 255. Keep this in mind as work on the following problems, as it may be important for correct results. These are problems are listed in increasing order of difficulty (and credit). You may attempt as many (or as few) as you like. EC1: Black Box Write a function that superimposes a black box on the center 50Times50 pixel region of your image. EC2: Counting Brightness Write a function that counts the number of bright pixels in an image - i.e., those whose color values sum to more than some threshold, which should be an input to your function. Test it with a threshold value of 600. EC3: Flip Me Over Write a function that flips the image vertically (the pixels at the top are now at the bottom and vice versa). Do not use the built in flip or similar functions, you must write this function from scratch. EC4: Spinnin' Around Write a function that rotates the image 90 degrees to the right. Be aware that the rot90 function will not work without some extra steps on your part.

Explanation / Answer


1) Black-box function { file blackbox.m}


function I = blackbox(img)
    I=double(img);
   
    rows=size(img,1);
    cols=size(img,2);
   
    if(mod(rows,2)==0)
        mid_row=rows/2;
    else
        mid_row=rows/2 + 1;
    end
   
    if(mod(cols,2)==0)
        mid_col=cols/2;
    else
        mid_col=cols/2 + 1;
    end
   
    I(mid_row-25+1:mid_row+25,mid_col-25+1:mid_col+25,1) = 0;
    I(mid_row-25+1:mid_row+25,mid_col-25+1:mid_col+25,2) = 0;
    I(mid_row-25+1:mid_row+25,mid_col-25+1:mid_col+25,3) = 0;
   
    I =uint8(I);   
end


_______________________________________________________________________________


2) counting brightness function {file count_bright.m}


function count = count_bright(img,threshold)
    img=double(img);
    count=0;


    for i=1:size(img,1)
        for j=1:size(img,2)
            if((img(i,j,1)+img(i,j,2)+img(i,j,3))>threshold)
                count = count+1;
            end
        end
    end


    str=sprintf('Number of pixels above %d = %d',threshold,count);
    disp(str);


end


_______________________________________________________________________________



image-file:

http://www.google.co.in/imgres?sa=X&biw=1366&bih=665&tbm=isch&tbnid=jKDZ4vXtzhpvtM%3A&imgrefurl=http%3A%2F%2Fffreport.forumcommunity.net%2F%3Ft%3D51937067&docid=A6oK2-zAoelFWM&imgurl=http%3A%2F%2Fwww.ce.unipr.it%2F~mazzei%2Fteaching%2Fvisione%2Fimmagini%2Flena.png&w=512&h=512&ei=BVUfU-fzNIfUrQeix4DQBw&zoom=1&ved=0CGEQhBwwBQ&iact=rc&dur=898&page=1&start=0&ndsp=21


Download this image in your folder along with the other code files


_______________________________________________________________________________


Main-program to test the functions {file test.m}


close all;
clear;

I = imread('lena.png');    %reading lena.png image, you can use any other image if you want


I_new=blackbox(I); %calling blackbox-function for image I
figure,imshow(I);
figure,imshow(I_new);

count=count_bright(I,600); %calling blackbox-function for image I with threshold=600


___________________________________________________________________________________


Output: