Histograms 1D Histograms 3D Histograms Equalisation

Slides:



Advertisements
Similar presentations
K-means Clustering Given a data point v and a set of points X,
Advertisements

Unsupervised Learning Clustering K-Means. Recall: Key Components of Intelligent Agents Representation Language: Graph, Bayes Nets, Linear functions Inference.
1 Machine Learning: Lecture 10 Unsupervised Learning (Based on Chapter 9 of Nilsson, N., Introduction to Machine Learning, 1996)
Features Induction Moravec Corner Detection
Histograms and Matching 主講人:虞台文. Content Overview Basic Histogram Structure Accessing Histograms Basic Manipulations with Histograms Color Spaces Histogram.
Image Segmentation Image segmentation (segmentace obrazu) –division or separation of the image into segments (connected regions) of similar properties.
CS324e - Elements of Graphics and Visualization Color Histograms.
電腦視覺 Computer and Robot Vision I Chapter2: Binary Machine Vision: Thresholding and Segmentation Instructor: Shih-Shinh Huang 1.
Recognition Template Matching Statistical Pattern Recognition (SPR)
Assessment. Schedule graph may be of help for selecting the best solution Best solution corresponds to a plateau before a high jump Solutions with very.
Human-Computer Interaction Human-Computer Interaction Segmentation Hanyang University Jong-Il Park.
Video Introduction Background Models Tracking Performance
Introduction to Bioinformatics
Lecture 3 More programming in OpenCV Slides by: Clark F. Olson.
Edge Detection Contour Segmentation Hough Transform
CS292 Computational Vision and Language Pattern Recognition and Classification.
Mutual Information Mathematical Biology Seminar
Clustering… in General In vector space, clusters are vectors found within  of a cluster vector, with different techniques for determining the cluster.
Advancing Wireless Link Signatures for Location Distinction J. Zhang, M. H. Firooz, N. Patwari, S. K. Kasera MobiCom’ 08 Presenter: Yuan Song.
MSU CSE 803 Stockman Linear Operations Using Masks Masks are patterns used to define the weights used in averaging the neighbors of a pixel to compute.
Basic Data Mining Techniques
Pattern Classification All materials in these slides were taken from Pattern Classification (2nd ed) by R. O. Duda, P. E. Hart and D. G. Stork, John Wiley.
Dimension reduction : PCA and Clustering Christopher Workman Center for Biological Sequence Analysis DTU.
Basics: Notation: Sum:. PARAMETERS MEAN: Sample Variance: Standard Deviation: * the statistical average * the central tendency * the spread of the values.
Computing IV Chapter Three: imgproc module Image Processing Xinwen Fu.
Dorin Comaniciu Visvanathan Ramesh (Imaging & Visualization Dept., Siemens Corp. Res. Inc.) Peter Meer (Rutgers University) Real-Time Tracking of Non-Rigid.
Images  Camera models  Digital images  Colour images  Noise  Smoothing Images Based on A Practical Introduction to Computer Vision with OpenCV by.
MSU CSE 803 Linear Operations Using Masks Masks are patterns used to define the weights used in averaging the neighbors of a pixel to compute some result.
Radial Basis Function (RBF) Networks
כמה מהתעשייה? מבנה הקורס השתנה Computer vision.
Evaluating Performance for Data Mining Techniques
Introduction to Image Processing Grass Sky Tree ? ? Review.
CSE 185 Introduction to Computer Vision Pattern Recognition.
Unsupervised Learning and Clustering k-means clustering Sum-of-Squared Errors Competitive Learning SOM Pre-processing and Post-processing techniques.
Machine Vision for Robots
Manipulating contrast/point operations. Examples of point operations: Threshold (demo) Threshold (demo) Invert (demo) Invert (demo) Out[x,y] = max – In[x,y]
COMMON EVALUATION FINAL PROJECT Vira Oleksyuk ECE 8110: Introduction to machine Learning and Pattern Recognition.
L. Akshay Masare Piyush Awasthi IMAGE PROCESSING AND OPENCV.
Seeram Chapter #3: Digital Imaging
Binary Thresholding Threshold detection Variations
Point Operations – Chapter 5. Definition Some of the things we do to an image involve performing the same operation on each and every pixel (point) –We.
Lecture 3 The Digital Image – Part I - Single Channel Data 12 September
MACHINE LEARNING 8. Clustering. Motivation Based on E ALPAYDIN 2004 Introduction to Machine Learning © The MIT Press (V1.1) 2  Classification problem:
CVPR2013 Poster Detecting and Naming Actors in Movies using Generative Appearance Models.
Levels of Image Data Representation 4.2. Traditional Image Data Structures 4.3. Hierarchical Data Structures Chapter 4 – Data structures for.
Chapter Outline Goodness of Fit test Test of Independence.
LUT Method For Inverse Halftone 資工四 林丞蔚 林耿賢. Outline Introduction Methods for Halftoning LUT Inverse Halftone Tree Structured LUT Conclusion.
Machine Learning Queens College Lecture 7: Clustering.
Vector Quantization CAP5015 Fall 2005.
Database Management Systems, R. Ramakrishnan 1 Algorithms for clustering large datasets in arbitrary metric spaces.
CS654: Digital Image Analysis
A Statistical Approach to Texture Classification Nicholas Chan Heather Dunlop Project Dec. 14, 2005.
1 1 Slide © 2008 Thomson South-Western. All Rights Reserved Chapter 12 Tests of Goodness of Fit and Independence n Goodness of Fit Test: A Multinomial.
Learning Kernel Classifiers 1. Introduction Summarized by In-Hee Lee.
Performance Measurement of Image Processing Algorithms By Dr. Rajeev Srivastava ITBHU, Varanasi.
Color Image Segmentation Mentor : Dr. Rajeev Srivastava Students: Achit Kumar Ojha Aseem Kumar Akshay Tyagi.
Unsupervised Classification
1 Kernel Machines A relatively new learning methodology (1992) derived from statistical learning theory. Became famous when it gave accuracy comparable.
Pixel Purity Index Assumes spectrally “pure” pixels are likely to correspond to “in scene” end members   For i = 1 to N Randomly generate a unit vector.
Gaussian Mixture Model classification of Multi-Color Fluorescence In Situ Hybridization (M-FISH) Images Amin Fazel 2006 Department of Computer Science.
Computer Vision Set: OpenCV programming Slides by D.A. Forsyth, C.F. Olson, J. Ponce, L.G. Shapiro More programming in OpenCV.
Semi-Supervised Clustering
Ke Chen Reading: [7.3, EA], [9.1, CMB]
1-Introduction (Computing the image histogram).
The Earth Mover's Distance
Ke Chen Reading: [7.3, EA], [9.1, CMB]
Pattern Classification All materials in these slides were taken from Pattern Classification (2nd ed) by R. O. Duda, P. E. Hart and D. G. Stork, John.
Histogram Equalization with Cell Broadband Engine™
Image Segmentation.
Pattern Classification All materials in these slides were taken from Pattern Classification (2nd ed) by R. O. Duda, P. E. Hart and D. G. Stork, John.
Presentation transcript:

Histograms 1D Histograms 3D Histograms Equalisation Histogram Comparison Back Projection k-means clustering Histograms Based on A Practical Introduction to Computer Vision with OpenCV by Kenneth Dawson-Howe © Wiley & Sons Inc. 2014

1D Histograms Determine the frequency of brightness values Initialise: h(z) = 0 for all values of z Compute: For all pixels (i.j): h(f(i,j))++ Histograms Based on A Practical Introduction to Computer Vision with OpenCV by Kenneth Dawson-Howe © Wiley & Sons Inc. 2014

1D Histograms Is this useful? Global information Useful for classification ? Not unique Histograms Based on A Practical Introduction to Computer Vision with OpenCV by Kenneth Dawson-Howe © Wiley & Sons Inc. 2014

1D Histograms Mat display_image; MatND histogram; const int* channel_numbers = { 0 }; float channel_range[] = { 0.0, 255.0 }; const float* channel_ranges = channel_range; int number_bins = 64; calcHist( &gray_image, 1, channel_numbers, Mat(), histogram, 1, &number_bins, &channel_ranges ); OneDHistogram::Draw1DHistogram( &gray_histogram, 1, display_image ); imshow("Greyscale histogram", display_image); Histograms Based on A Practical Introduction to Computer Vision with OpenCV by Kenneth Dawson-Howe © Wiley & Sons Inc. 2014

1D Histograms – Smoothing Local minima and maxima are useful. But how can we deal with noise though? Smooth the histogram… For all values v: hnew(v) = ( h(v-1) + h(v) + h(v+1) ) / 3 What do we do at the ends? Do not compute OR Wraparound OR Duplicate values OR Reflect values OR Constant values ?? Histograms Based on A Practical Introduction to Computer Vision with OpenCV by Kenneth Dawson-Howe © Wiley & Sons Inc. 2014

1D Histograms – Smoothing MatND smoothed_histogram = histogram[channel].clone(); for(int i = 1; i < histogram[channel].rows - 1; ++i) smoothed_histogram[channel].at<float>(i) = (histogram.at<float>(i-1) + histogram.at<float>(i) + histogram.at<float>(i+1)) / 3; Histograms Based on A Practical Introduction to Computer Vision with OpenCV by Kenneth Dawson-Howe © Wiley & Sons Inc. 2014

1D Histograms – Colour Histograms Determine histograms for each channel independently… Choice of colour space… Histograms Based on A Practical Introduction to Computer Vision with OpenCV by Kenneth Dawson-Howe © Wiley & Sons Inc. 2014

1D Histograms – Colour Histograms Based on A Practical Introduction to Computer Vision with OpenCV by Kenneth Dawson-Howe © Wiley & Sons Inc. 2014

1D Histograms – Colour Histograms MatND* histogram = new MatND[image.channels() ]; vector<Mat> channels(image.channels() ); split( image, channels ); const int* channel_numbers = { 0 }; float channel_range[] = { 0.0, 255.0 }; const float* channel_ranges = channel_range; int number_bins = 64; for (int chan=0; chan < image.channels(); chan++) calcHist( &(channels[chan]), 1, channel_numbers, Mat(), histogram[chan], 1, &number_bins, &channel_ranges ); OneDHistogram::Draw1DHistogram(histogram, image.channels(), display_image ); Histograms Based on A Practical Introduction to Computer Vision with OpenCV by Kenneth Dawson-Howe © Wiley & Sons Inc. 2014

3D Histograms Channels are not independent Better discrimination comes from considering all channels simultaneously Number of cells? 8 bits =16,777,216 Histograms Based on A Practical Introduction to Computer Vision with OpenCV by Kenneth Dawson-Howe © Wiley & Sons Inc. 2014

3D Histograms Reduce quantisation 6 bits = 262,144 4 bits = 4,096 Based on A Practical Introduction to Computer Vision with OpenCV by Kenneth Dawson-Howe © Wiley & Sons Inc. 2014

3D Histograms MatND histogram; int channel_numbers[] = { 0, 1, 2 }; int* number_bins = new int[image.channels()]; for (ch=0; ch < image.channels(); ch++) number_bins[ch] = 64; float ch_range[] = { 0.0, 255.0 }; const float* channel_ranges[] = {ch_range, ch_range, ch_range}; calcHist( &image, 1, channel_numbers, Mat(), histogram, image.channels(), a_number_bins, channel_ranges ); Histograms Based on A Practical Introduction to Computer Vision with OpenCV by Kenneth Dawson-Howe © Wiley & Sons Inc. 2014

Equalisation If an image has insufficient contrast Human can distinguish 700-900 greyscales Evenly distribute the greyscales… Result has missing greyscales Normally equalise only the greyscales / luminance Histograms Based on A Practical Introduction to Computer Vision with OpenCV by Kenneth Dawson-Howe © Wiley & Sons Inc. 2014

Equalisation // Create a lookup table to map the luminances // h[x] = histogram of luminance values image f(i,j). pixels_so_far = 0 num_pixels = image.rows * image.cols output = 0 for input = 0 to 255 pixels_so_far = pixels_so_far + h[ input ] new_output = (pixels_so_far*256) / (num_pixels+1) LUT[ input ] = (output+1+new_output) / 2 output = new_output // Apply the lookup table LUT(x) to the image: for every pixel f(i,j) f’(i,j) = LUT[ f(i,j) ] Histograms Based on A Practical Introduction to Computer Vision with OpenCV by Kenneth Dawson-Howe © Wiley & Sons Inc. 2014

Equalisation split(hls_image, channels); vector<Mat> channels( hls_image.channels() ); equalizeHist( channels[1], channels[1] ); merge( channels, hls_image ); Histograms Based on A Practical Introduction to Computer Vision with OpenCV by Kenneth Dawson-Howe © Wiley & Sons Inc. 2014

Histogram Comparison To find similar images… Use metadata Compare images Compare the colour distributions Need a metric for comparisons… Histograms Based on A Practical Introduction to Computer Vision with OpenCV by Kenneth Dawson-Howe © Wiley & Sons Inc. 2014

Histogram Comparison Histograms Based on A Practical Introduction to Computer Vision with OpenCV by Kenneth Dawson-Howe © Wiley & Sons Inc. 2014

Histogram Comparison – Metrics Histograms Based on A Practical Introduction to Computer Vision with OpenCV by Kenneth Dawson-Howe © Wiley & Sons Inc. 2014

Histogram Comparison – Earth Mover An alternative to the metrics is to compute the Earth Mover’s Distance… Minimum cost for turning a distribution into another distribution Compare images 1D solution: EMD(-1) = 0 EMD(i) = h1(i) + EMD(i-1) - h2(i) Earth Mover’s Distance = Σi | EMD(i) | Colour EMD is harder to compute… Histograms Based on A Practical Introduction to Computer Vision with OpenCV by Kenneth Dawson-Howe © Wiley & Sons Inc. 2014

Histogram Comparison normalize( histogram1, histogram1, 1.0); double matching_score = compareHist( histogram1, histogram2, CV_COMP_CORREL); We can also use Chi-Square (CV_COMP_CHISQR), Intersection (CV_COMP_INTERSECT) or Bhattacharyya (CV_COMP_BHATTACHARYYA) metrics or alternatively can use the Earth Mover’s Distance function (EMD()) Histograms Based on A Practical Introduction to Computer Vision with OpenCV by Kenneth Dawson-Howe © Wiley & Sons Inc. 2014

Histogram Back Projection A better approach to selecting colours (based on samples): Obtain a representative sample set of the colours. Histogram those samples. Normalize that histogram so that the maximum value is 1.0. Back project the normalized histogram onto any image f(i,j). This will provide a ‘probability’ image p(i,j) which indicates the similarity between f(i,j) and the sample set. Histograms Based on A Practical Introduction to Computer Vision with OpenCV by Kenneth Dawson-Howe © Wiley & Sons Inc. 2014

Histogram Back Projection calcHist( &hls_samples_image, 1, channel_numbers, Mat(), histogram,image.channels(),number_bins,channel_ranges); normalize( histogram, histogram, 1.0); Mat probabilities = histogram.BackProject( hls_image ); Histograms Based on A Practical Introduction to Computer Vision with OpenCV by Kenneth Dawson-Howe © Wiley & Sons Inc. 2014

k means Clustering We’d like to How do we find the best colours? identify significant colours in images Concise descriptions Object tracking reduce the number of colours in any image Compression How do we find the best colours? k means clustering Creates k clusters of pixels Unsupervised learning Histograms Based on A Practical Introduction to Computer Vision with OpenCV by Kenneth Dawson-Howe © Wiley & Sons Inc. 2014

k means Clustering – Algorithm Number of clusters (k) is known in advance (or determine the k with the maximum confidence) Initialise the k cluster exemplars either randomly or use the first k patterns or … 1st pass: Allocate patterns to the closest existing cluster exemplar and recompute the exemplar as the centre of gravity 2nd pass: Using the final exemplars from the first pass allocate all patterns cluster exemplars. Histograms Based on A Practical Introduction to Computer Vision with OpenCV by Kenneth Dawson-Howe © Wiley & Sons Inc. 2014

k means Clustering Histograms Based on A Practical Introduction to Computer Vision with OpenCV by Kenneth Dawson-Howe © Wiley & Sons Inc. 2014

k means Clustering Different values of k (10, 15 & 20 random exemplars): Not all clusters end up with patterns More exemplars generally gives a more faithful representation Histograms Based on A Practical Introduction to Computer Vision with OpenCV by Kenneth Dawson-Howe © Wiley & Sons Inc. 2014

k means Clustering Choosing the best number of exemplars Evaluate the resulting clusters Davies-Bouldin index measures cluster separation: DB = 1/k Σ1..k maxi≠j ((Δi + Δj)/ δi.j) OR Check that distributions are normal Histograms Based on A Practical Introduction to Computer Vision with OpenCV by Kenneth Dawson-Howe © Wiley & Sons Inc. 2014

k means Clustering Using random exemplars gives non-deterministic results (30 random exemplars each time): Histograms Based on A Practical Introduction to Computer Vision with OpenCV by Kenneth Dawson-Howe © Wiley & Sons Inc. 2014

k means Clustering // Store the image pixels as an array of samples Mat samples(image.rows*image.cols, 3, CV_32F); float* sample = samples.ptr<float>(0); for(int row=0; row<image.rows; row++) for(int col=0; col<image.cols; col++) for (int channel=0; channel < 3; channel++) samples.at<float>(row*image.cols+col,channel) = (uchar) image.at<Vec3b>(row,col)[channel]; // Apply k-means clustering, determining the cluster // centres and a label for each pixel. …. Histograms Based on A Practical Introduction to Computer Vision with OpenCV by Kenneth Dawson-Howe © Wiley & Sons Inc. 2014

k means Clustering Mat labels, centres; kmeans(samples, k, labels, TermCriteria( CV_TERMCRIT_ITER| CV_TERMCRIT_EPS, 0.0001, 10000), iterations, KMEANS_PP_CENTERS, centres ); // Use centres and label to populate result image Mat& result_image = Mat( image.size(), image.type() ); for(int row=0; row<image.rows; row++) for(int col=0; col<image.cols; col++) for (int channel=0; channel < 3; channel++) result_image.at<Vec3b>(row,col)[channel] = (uchar) centres.at<float>( *(labels.ptr<int>( row*image.cols+col )), channel); Histograms Based on A Practical Introduction to Computer Vision with OpenCV by Kenneth Dawson-Howe © Wiley & Sons Inc. 2014