Tuesday, February 7, 2017

Matlab code: "histcounts"

Previous week, I was able to match an image with a template and plot where it matched up most, giving a 3D surface plot of "peaks." For this week, the goal is to create a script that can count the number of peaks. After discussing with Dr. Vernizzi, we decided to try Matlab's function histcounts2 to bin nearby data points together so that it only counts the maximum value of each peak. So this week I will test out the following codes:

[X,Y] = find(c>0)  % this sets the threshold to count points above 0
histcounts2(X,Y,[50:50])  %sets bin size (the max bin size should be the number of pixels in c matrix)
length(find(N>0))  %gives the number of points found in histcounts

I plan on testing this first with a "test" image randomly generated by Matlab. 

Thursday, February 2, 2017

Matlab: Normalized Cross-Correlation (NCC)

Read several articles on computational object counting using convolution based pattern matching technique.

Some important notes I found:
  • Convolution filtering is used to modify the spatial frequency characteristics of an image.
  • General purpose filter effect for images
  • A matrix applied to an image and a mathematical operation comprised of integers
  • Works by determining the value of a central pixel by adding the weighted values of all its neighbors together
  • A kernel is a (usually) small matrix of numbers that is used in image convolutions-  3x3 is often used
  • ‡Why convolve an image? Smooth ‡ Sharpen ‡ Intensify ‡ Enhance


Template matching- match a template to an image where the template pattern is a part of the source image that contains the shape inside it
  • Template shifts in x and y direction (u,v) over image and repeated for entire image
  • Best match/peak value is point where the shape lie within the source image


Based on this, I created a template from one of the SEM images and tested out a Matlab function:
normxcorr2( )


This function gives the normalized 2D cross-correlation of matrices 'template' and 'image.' It finds where the values match up best so that we can pinpoint each particle.


Image and template side by side. The template (right) is one of the particles cropped from the image (left)



Surface image of matching values in between the image and the template. Higher values signify better match.


Plot of the peak x and y values

Next week,  I will work on a script that will count the peak values. The problem I ran into with the code is that there are duplicate x and y peaks that overlap one another or values that are very similar to one another making it seem like there is more than one "match" per particle. A function that I will try is histcounts( ) to bin similar values together and then count the bins to represent number of particles.

References:

Counting Objects using Convolution based Pattern Matching Technique
http://research.ijais.org/volume5/number8/ijais13-450964.pdf
Image Convolution
http://web.pdx.edu/~jduh/courses/Archive/geog481w07/Students/Ludwig_ImageConvolution.pdf

Tuesday, January 24, 2017

1/20/17 Meeting with Dr Vernizzi

I met with Dr Vernizzi for an hour to review what was done  last semester and what our plan is for this semester. We discussed which method to test for our Matlab function. We are going to try the Fourier Transform to find the particles in the SEM images. For this week, I plan on reading up on Fourier Transforms and test it with some of the SEM images.