I need help with this Image Processing HW

12 views (last 30 days)
I've been working on this over a week and still can figure out how to do them. For each of the questions I'll describe what I'm having trouble with. 1.On this one I can't seem to figure out how to make a border with on the image, I was thinking there was a function. 2.When I try to multiply the image array by 2 it also multiplies the RGB part, my img(:,:,6). 3.I can find the average values of each color channel but I'm not sure how to apply them to the image without it turning gray. 5. Part 5 just makes no sense.
I've contacted my professor but can't set a time that will accommodate both of our schedules. I'm not asking for the answer itself but more like an approach and what am I doing wrong.

Answers (2)

Ameer Hamza
Ameer Hamza on 1 May 2018
Since it is an HW question so I cannot provide the answer in detail. Here are few functions which will help you padarray(), imresize(). As far as the code you gave is concerned, it becomes 255 because you are calculating with uint8 which can store a maximum value of 255. You should probably think about converting the matrix to some more flexible datatype.

Florian Morsch
Florian Morsch on 2 May 2018
For the first question you can try something like this:
ImageWithFrame = insertShape(Image, 'Polygon', bboxPolygon, 'LineWidth', 5, 'Color', 'red');
imshow(ImageWithFrame);
What this does is inserting a Polygon with the coordinates bboxPolygon ( x1 y1, x2 y2, x3 y3, x4 y4) with a line width of 5 and the color red. Now you just need to change the parameters for the bounding box so all your sides are the same amount of pixels (simple math) and you can change the
'red'
to a vecor with the RGB values, then just change those values to the desired color.
For the second question: just get you image size with
ImageSize = size(image);
You will get the width and height of the image. Now you can multiply these values by 2 and create a new image or use
imresize()
For 3: You can extract all colors with something like this:
img = imread('filename.png'); % Read image
red = img(:,:,1); % Red channel
green = img(:,:,2); % Green channel
blue = img(:,:,3); % Blue channel
a = zeros(size(img, 1), size(img, 2));
just_red = cat(3, red, a, a);
just_green = cat(3, a, green, a);
just_blue = cat(3, a, a, blue);
back_to_original_img = cat(3, red, green, blue);
figure, imshow(img), title('Original image')
figure, imshow(just_red), title('Red channel')
figure, imshow(just_green), title('Green channel')
figure, imshow(just_blue), title('Blue channel')
figure, imshow(back_to_original_img), title('Back to original image')
Now you just need to get all of those images to your desired size and position, but i think you can do it.
Last but not least: 5 makes total sense, you should write a script which takes a RGB image as input and returns a red, a green and a blue picture of the same image. The first returned image should only have red with green and blue zero, the second only green with red and blue zero and the third only blue with red and green zero. Just take a look at the code i posted in 3, it should help to solve that problem.

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!