How to find minimum and maximum values of the motion blur angle from cepstrum and Initialize the accumulator array?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Vimal Raj
am 11 Jan. 2023
Beantwortet: Shubham
am 3 Mai 2023
This is the algorithm i followed to estimate angle from hough transform but, im not getting the proper result as shown in reference (input=lena image) reference output for length=10 and theta=60.
Algorithm:
1. Convert blurred RGB image ( ) to gray level image ( ).
2. Perform Hann windowing over the image to remove boundary artefacts.
3. Compute the Fourier transform F(u, v) of step2 image.
4. Compute the log spectrum of F(u,v).
5. Compute the inverse Fourier transform of log spectrum.
6. Find the edge map of the cepstral of step 5.
7. Let α min and the α max be the minimum and maximum values of the motion blur angle.
8. Initialize the accumulator array A(r,α) to zero.
9. Repeat for each edge point (xi, yi)
Repeat for α = αmin to αmax
{
r = xi cos α + yi sin α
A(r,α) = A(r,α) + 1
α = α +1
}
10. Find the peak in Hough transform (the maximum value in accumulator array) which is perpendicular to the motion blur angle.
Code:
img = rgb2gray( imread('C:\Users\OneDrive\Desktop\lena.png'));
theSpectrum = abs(fftshift(fft2(img)));
Cepstrumm = MakeCepstrum ( img );
[H,T,R] = hough(Cepstrumm);
imshow(imadjust(mat2gray(H)), [], 'XData',T, 'YData',R, ...
'InitialMagnification','fit')
xlabel('\theta (degrees)'), ylabel('\rho')
axis on, axis normal, hold on
colormap(hot), colorbar
kindly help me to plot the same. Thank you.
0 Kommentare
Akzeptierte Antwort
Shubham
am 3 Mai 2023
Hi Vimal,
To get the minimum and maximum values of the motion blur angle from the cepstrum, you just need to find the peak in the cepstrum that corresponds to the blur angle.
This peak will be a horizontal line in the cepstrum, and its location in the horizontal direction will correspond to the blur angle. You can use the max function to find the location of this peak in the cepstrum, and then convert the location to an angle using the formula angle = 180 - (location / size(cepstrum, 2)) * 180.
To initialize the accumulator array, you need to determine the range of possible blur angles. This range will depend on the application and the image being analyzed. Once you have determined the range, you can create an accumulator array with dimensions that cover the range of possible blur angles and the range of possible values of r. You can use the zeros function to initialize the accumulator array to zero.
Providing an example code snippet to get you the better clarity on finding a minimum and maximum blur angles from the cepstrum and initialize the accumulator array:
img = rgb2gray(imread('C:\Users\OneDrive\Desktop\lena.png'));
cepstrum = MakeCepstrum(img);
[~, max_location] = max(cepstrum(1:end/2, :)); % Find location of peak in cepstrum
blur_angle = 180 - (max_location / size(cepstrum, 2)) * 180; % Convert location to angle
alpha_min = blur_angle - 10; % Set range of possible blur angles
alpha_max = blur_angle + 10;
accumulator = zeros(size(img, 1), alpha_max - alpha_min + 1); % Initialize accumulator array
Note that in this example, the range of possible blur angles is set to 20 degrees around the detected blur angle. You can adjust this range as needed.
To plot the Hough transform, you can use the imshow function with the 'XData' and 'YData' options to specify the axes labels, and the 'InitialMagnification' option to set the initial zoom level. Here's an example code snippet that shows how to plot the Hough transform:
[H, T, R] = hough(cepstrum);
accumulator = houghpeaks(H, 1); % Find peak in Hough transform
alpha = alpha_min + accumulator(2) - 1; % Convert peak location to angle
imshow(imadjust(mat2gray(H)), [], 'XData', T, 'YData', R, ...
'InitialMagnification', 'fit');
xlabel('\theta (degrees)'), ylabel('\rho');
axis on, axis normal, hold on;
colormap(hot), colorbar;
plot(T(accumulator(2)), R(accumulator(1)), 's', 'color', 'white');
In this example, the houghpeaks function is used to find the peak in the Hough transform. The location of the peak is then converted to an angle and plotted as a white square on the Hough transform.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Multirate Signal Processing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!