Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programming Assignment 3 CS 302 - Data Structures Dr. George Bebis.

Similar presentations


Presentation on theme: "Programming Assignment 3 CS 302 - Data Structures Dr. George Bebis."— Presentation transcript:

1 Programming Assignment 3 CS 302 - Data Structures Dr. George Bebis

2 Goal: Represent image regions using lists and perform galaxy classification Builds on previous two programming assignments. (1) Represent image regions in a list for easier processing. (2) Compute region features.

3 Project Objectives Improve your skills with manipulating unsorted/sorted lists Improve your skills with using templates Learn about feature extraction and classification.

4 Region Features Image regions can be characterized using various features: –Geometric –Photometric

5 Geometric Features The geometry of a region can be characterized using: –Size –Position –Orientation –Shape (e.g., circular, elliptical) Many of these features could be computed using a family of functions called moments.

6 Moments The moments of order (p,q) of a region R are: (i,j) є R Note: moments have their roots in probability theory and are used to characterize probability density functions (pdfs). - Mean (i.e., first order moment) - Variance (i.e., second order central moments).

7 Region Area (i.e., size) The area of a region is defined by the number of pixels in the region (i.e., size). Can be computed using zero order moments (i.e., p=q=0) : (i,j) є R

8 Region Center (i.e., centroid) The centroid of a region (i.e., center coordinates) can be computed using first order moments (p=1 or q=1):

9 Central Moments To make region descriptors invariant with respect to location, moments can be calculated with respect to the centroid of the region (i.e., central moments):

10 Principal Axes The principal axes of a region can be used to characterize the shape and orientation of a region. A min and A max

11 Principal Axes (cont’d) The principal axes, A min and A max, of a region can be computed using the principal moments λ min, λ max : The principal moments involve first and second order central moments:

12 Region Orientation The direction of the largest principal axis can be used to specify the orientation of a region:

13 Region Eccentricity (i.e., Elongatedness) A useful measure of a region’s circularity is its eccentricity (i.e., elongatedness). Can be easily computed using the ratio between the principal axes:

14 Example

15 Photometric Properties Measures characterizing region intensity, for example: –Mean and median of the gray-levels. –Minimum and maximum intensity values.

16 Object Classification - Example Objects could be classified in different categories using various region properties, for example: –Large/Small/Medium –Elongated/Circular

17 Represent regions in a sorted list: listOfRegions Geometric properties Intensity properties List of pixels x,y Geometric properties Intensity properties List of pixels x,y Geometric properties Intensity properties List of pixels x,y … listOfRegion: sorted with respect to “size” listOfPixels: unsorted Nodes store info about each region (i.e., “RegionType”) Sub-lists store the coordinates of pixels in each region - i.e., “PixelType” -- unsorted

18 Extra credit: template lists template struct NodeType { ItemType info; NodeType * next; }; listOfRegions: ItemType should be “RegionType” listOfPixels: ItemType should be “PixelType” Geometric properties Intensity properties List of pixels x,y you need to define them! This is object composition !

19 Extend computeComponents int computeComponents(inputImage, outputImage, listOfRegions) computeComponents should return the following info: –the labeled image (same as before) –the number of regions (same as before) –a list of regions (new) Modify BFS or DFS –Use one of them in this assignment

20 int computeComponents(inputImage, outputImage, listOfRegions) outputImage --> white connComp=0; for (i=0; i<N; i++) for(j=0; j<M; j++) if(inputImage[i][j] == 255 && outputImage[i][j]==255) { ++connComp; label = connComp; region findComponentDFS(inputImage, outputImage, i, j, label, region); region // or findComponentBFS(inputImage, outputImage, i, j, label, region); INSERT region into “listOfRegions” } return connComp; (client function) type “RegionType”

21 findComponentDFS(inputImage, outputImage, i, j, label, region) Stack.MakeEmpty(); Stack.Push((i,j)); // initialize stack while(!Stack.IsEmpty()) { Stack.Pop((pi,pj)); INSERT (pi,pj) into “listOfPixels” of “region” INSERT (pi,pj) into “listOfPixels” of “region” outputImage[pi][pj] = label * 10; for each neighbor (ni,nj) of (pi,pj) // push neighbors if(inputImage[ni][nj] == 255 && outputImage[ni][nj] == 255) { outputImage[ni][nj] = -1; // mark this pixel Stack.Push((ni,nj)); } COMPUTE geometric and photometric properties and populate “region” type RegionType Geometric properties Intensity properties List of pixels x,y

22 void deleteSmallComponents(listOfRegions, threshold) Step through the list nodes and delete all the regions whose size is less than a user-specified threshold (e.g., 20-30 pixels). (client function) Hint: You would not have to visit all the nodes since the list will be sorted from the smallest to the largest region! “deleteSmallComponents” will be useful for debugging your program (i.e., keep large regions only)

23 Classify regions Add a new option in the driver called “classify regions” Image Gallery 2 –Given an input image (i.e., from Image Gallery 2), your program should extract and represent the regions as described. –Prints a summary of the regions found and their properties (e.g., position, size, orientation, eccentricity, mean intensity etc.) –Prints min/max values of size, eccentricity, and mean intensity.

24 Classify regions (cont’d) Then, your program should print the following sub-menu: (1) display regions with size between values A and B (2) display regions with orientation between values A and B (3) display regions with eccentricity between A and B (4) display regions with mean intensity between A and B (5) back to the main menu

25 Display your results listOfRegionsTraverse listOfRegions Find the nodes satisfying the constraint chosen by the user listOfPixels –For each such node, traverse its listOfPixels –For each pixel, copy its original value in a new image Display the resulted image! original image output image Geometric properties Intensity properties List of pixels x,y Geometric properties Intensity properties List of pixels x,y Geometric properties Intensity properties List of pixels x,y … Example:


Download ppt "Programming Assignment 3 CS 302 - Data Structures Dr. George Bebis."

Similar presentations


Ads by Google