1. Computer vision assignment
CS559 – Computer Vision
Due 1:00 pm, Dec 7, 2022
- Suppose that the boundary of a closed region is represented by a 4-directional chain code. Write a function Area(ChainCode) in pseudo-code to compute the area of the region given its chain code representation.
- Show that the area enclosed by the polyline is
- Compare Hough transform and Canny edge detection for region detection in terms of (i) robustness (insensitivity) to noise, (ii) detection of regions with irregular shape, (iii) any common technique that is used both methods.
- (a) Compare three losses compressions techniques in terms of their suitability for natural images.
(b) Explain which lossless compression technique use variable code length. Which technique results in the optimal code length?
5, Consider the 8 by 8 subimage
Apply the JPEG compression algorithm (see lecture notes) and find and report the 1-D coefficient sequence.
- Use the region growing function (next page) to detect:
- The red, blue, green regions in the ThreeRegions image (next page) by planting one seed in each region simultaneously. You must run the program only once to detect all three regions. This requires just a little modification to the attached function.
- Determine the centroid, area, and circularity of the regions detected in (a)
- Find the minimum distance between the boundaries of the red and blue regions. Do not use your (human) vision and just assume that you have detected these two regions as in (a). You must come up with an efficient For example finding the distance of every pixel on the boundary of red region to every pixel in the boundary of blue region is inefficient.
Note: You must understand the code before applying it.
% This function performs “region growing” in an image from a specified
% seedpoint (x,y)
% J = regiongrowing(I,x,y,t)
% I : input image
% J : logical output image of region
% x,y : the position of the seedpoint (if not given uses function getpts)
% t : maximum intensity distance (defaults to 0.2)
% The region is iteratively grown by comparing all unallocated neighbouring pixels to the region.
% The difference between a pixel’s intensity value and the region’s mean,
% is used as a measure of similarity. The pixel with the smallest difference
% measured this way is allocated to the respective region.
% This process stops when the intensity difference between region mean and
% new pixel become larger than a certain treshold (t)
% I = im2double(imread(‘medtest.png’));
% x=198; y=359;
% J = regiongrowing(I,x,y,0.2);
% figure, imshow(I+J);
% Author: D. Kroon, University of Twente
if(exist(‘reg_maxdist’,’var’)==0), reg_maxdist=0.2; end
if(exist(‘y’,’var’)==0), figure, imshow(I,); [y,x]=getpts; y=round(y(1)); x=round(x(1)); end
J = zeros(size(I)); % Output
Isizes = size(I); % Dimensions of input image
reg_mean = I(x,y); % The mean of the segmented region
reg_size = 1; % Number of pixels in region
% Free memory to store neighbours of the (segmented) region
neg_free = 10000; neg_pos=0;
neg_list = zeros(neg_free,3);
pixdist=0; % Distance of the region newest pixel to the regio mean
% Neighbor locations (footprint)
neigb=[-1 0; 1 0; 0 -1;0 1];
% Start regiogrowing until distance between regio and posible new pixels become
% higher than a certain treshold
% Add new neighbors pixels
% Calculate the neighbour coordinate
xn = x +neigb(j,1); yn = y +neigb(j,2);
% Check if neighbour is inside or outside the image
% Add neighbor if inside and not already part of the segmented area
neg_pos = neg_pos+1;
neg_list(neg_pos,:) = [xn yn I(xn,yn)]; J(xn,yn)=1;
% Add a new block of free memory
if(neg_pos+10>neg_free), neg_free=neg_free+10000; neg_list((neg_pos+1):neg_free,:)=0; end
% Add pixel with intensity nearest to the mean of the region, to the region
dist = abs(neg_list(1:neg_pos,3)-reg_mean);
[pixdist, index] = min(dist);
% Calculate the new mean of the region
reg_mean= (reg_mean*reg_size + neg_list(index,3))/(reg_size+1);
% Save the x and y coordinates of the pixel (for the neighbour add proccess)
x = neg_list(index,1); y = neg_list(index,2);
% Remove the pixel from the neighbour (check) list
% Return the segmented area as logical matrix