Monday, July 13, 2020

Coursera | Computer Vision Basics

Coursera

Computer Vision Basics


ASSIGNMENT=2

%Wrire code to split the image into three equal parts and store them in B, G, R channels B = img(1:341,1:400); G = img(342:682,1:400); R = img(683:1023,1:400); %concatenate R,G,B channels and assign the RGB image to ColorImg variable ColorImg = cat(3, R, G, B); imshow(ColorImg) ----------------------------------------------------

ASSIGNMENT=3

img = imread('cameraman.tif'); [Gx, Gy] = imgradientxy(img); [Gmag, Gdir] = imgradient(Gx, Gy); ---------------------------------------------------

ASSIGNMENT=4

%Read the image img = imread('course1image.jpg'); [h, w] = size(img); oneThird = floor(h/3); B = img(1:oneThird, :); G = img(oneThird+1:(2*oneThird), :); R = img((2*oneThird+1):(3*oneThird), :); cent_x = (341/2-25); cent_y = (400/2-25); ref_img_region = double(G(cent_x:cent_x + 50, cent_y:cent_y + 50)); red_offset = offset(double(R(cent_x:cent_x + 50, cent_y:cent_y + 50)), ref_img_region); shifted_red = circshift(R, red_offset); blue_offset = offset(double(B(cent_x:cent_x + 50, cent_y:cent_y + 50)), ref_img_region); shifted_blue = circshift(B, blue_offset); ColorImg_aligned = cat(3, shifted_red, G, shifted_blue); imshow(ColorImg_aligned); % Find the minimun offset by ssd function [output] = offset(img1, img2) MIN = inf; for x = -10:10 for y = -10:10 temp = circshift(img1, [x, y]); ssd = sum((img2 - temp).^2, 'all'); if ssd < MIN MIN = ssd; output = [x, y]; end end end end

No comments:

Post a Comment