block processing to find local orientation of each block

5 次查看(过去 30 天)
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 个评论
Leon
Leon 2023-12-21
移动:DGM 2023-12-21
Hello, I would like to know if you are using the original image or the normalized image for estimating the image direction field

请先登录,再进行评论。

采纳的回答

Guillaume
Guillaume 2016-1-7
编辑:Guillaume 2016-1-7
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 个评论
Guillaume
Guillaume 2016-1-27
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 2021-12-18
编辑:ALI Salah 2021-12-18
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

请先登录,再进行评论。

更多回答(1 个)

Image Analyst
Image Analyst 2016-1-7
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 个评论
Gunjan
Gunjan 2016-1-8
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
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

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by