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 个评论
采纳的回答
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
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
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
更多回答(1 个)
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 个评论
Bekhtaoui Abdelhakim
2019-3-23
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!