block processing to find local orientation of each block

3 views (last 30 days)
I want to implement an algorithm in MATLAB on a Fingerprint image in order to enhance it. The algorithm starts with normalization then orientation image estimation followed by three more steps. I have completed the normalization part but stuck at the orientation step for which following are the steps: 1) Divide the image into 16x16 blocks. 2) Compute the gradient at each pixel. 3) Estimate the local orientation of each block centered at pixel(i,j) using the below
Here delX and delY are gradients at each pixel. Vx(i,j) and Vy(i,j) are orientations.
function [imgOrient] = orientation(imgNorm)
Grad =@(block_struct)gradient(block_struct.data)
imgBlock=blockproc(ingNorm, [16 16], 'Grad)
Please let me know if this is correct way to use blockproc. Now I want to ask that how to save both the both the components (x as well as y ) returned by gradient function and use them in above formula. Any help would be appreciated.
  1 Comment
Leon
Leon on 21 Dec 2023
Moved: DGM on 21 Dec 2023
Hello, I would like to know if you are using the original image or the normalized image for estimating the image direction field

Sign in to comment.

Accepted Answer

Guillaume
Guillaume on 7 Jan 2016
Edited: Guillaume on 7 Jan 2016
Your code at present is just equivalent to
imgBlock = gradient(imgNorm);
Not really what you want.
What you want to do is pass to blockproc a function that returns a single value for each block, the orientation. You can't do it with an anonymous function (well, you could but that would be very unwieldy), so use a normal function:
function orientation = CalculateBlockOrientation(block_struct)
%block_struct: block structure generated by blockproc
%orientation: the orientation of the block
[delx, dely] = gradient(block_struct.data);
Vx = sum(sum(2*delx.*dely));
Vy = ... %I'm sure you can work it out
orientation = 0.5*atan(Vy/Vx);
end
And in your main function
blockorientation = blockproc(imgNorm, [16, 16], @CalculateBlockOrientation);
  13 Comments
Guillaume
Guillaume on 27 Jan 2016
Right, so the filtering is done on the orientation and is done outside of blockproc. This corresponds to the 1st part of my answer:
blockorientation = blockproc(imgNorm, [16, 16], @CalculateBlockOrientation); %CalculateBlockOrientation is unchanged
phi_x = cos(2*blockorientation);
phi_y = sin(2*blockorientation);
w = ones(5) / 25;
phi_x_prime = conv2(phi_x, w, 'same');
phi_y_prime = conv2(phi_y, w, 'same');
ALI Salah
ALI Salah on 18 Dec 2021
Edited: ALI Salah on 18 Dec 2021
hi Guillaume the function CalculateBlockOrientation will return the oriantation of each block in normimg but the question is how can i abtain new oriantation for each block based on
thetax(i,j) = cos(2*blockorientation);
thetay(i,j) = sin(2*blockorientation);
and theta=0.5*tan((thetax(i,j))'/(thetay(i,j))');
the last 3 equation below
note that in the formula above of Gunjan on 27 Jan 2016

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 7 Jan 2016
Each block will have a variety of gradients in it. The Computer Vision System Toolbox has a HOG detector (Histogram Of Gradients), where you can find the dominant direction and other info about the texture. See http://www.mathworks.com/help/vision/examples/digit-classification-using-hog-features.html?prodcode=VP&language=en
  2 Comments
Gunjan
Gunjan on 8 Jan 2016
Thank you for this information. Which type of function this gradient function do and how many neighborhoods it considers? What if I want to apply Marr-Hildreth or Sobel ? As the gradient function is slow so I want to get some knowledge about customizing this function.
Bekhtaoui Abdelhakim
Bekhtaoui Abdelhakim on 23 Mar 2019
hello mr Gunjan i have a probleme with the orientation estimation code I wonder if you could send your final code in my email hakimbekhtaoui23@gmail.com
thank you

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!