Understanding a piece of code about extracting regions within an image
1 view (last 30 days)
Show older comments
This is a licence plate extraction code. I have posted earlier a piece of code ( link ) where horizontal and vertical histograms representing the sum of differences of gray values between neighboring pixels in an image, column-wise and row-wise were used. A low pass filter was then applied on the histograms. After that, a threshold was applied in order to eliminate regions with low histogram values. Finaly, the algorithm finds the probabls regions and extracts the region with the highest probability of containing the license plate among those regions. I understand the whole idea but i have difficultie understanding the steps followed by the algorithm. PS: horz and vert are respectively the horizontal and vertical histograms after being passed through a low filter. why did he give the value of 'i' to column(j)? What do these lines refer to : [temp column_size] = size (column); if(mod(column_size, 2)) column(column_size+1) = cols?
if true
% %%Find Probable candidates for Number Plate
j = 1;
for i = 2:cols-2
if(horz(i) ~= 0 && horz(i-1) == 0 && horz(i+1) == 0)
column(j) = i;
column(j+1) = i;
j = j + 2;
elseif((horz(i) ~= 0 && horz(i-1) == 0) || (horz(i) ~= 0 && horz(i+1) == 0))
column(j) = i;
j = j+1;
end
end
j = 1;
for i = 2:rows-2
if(vert(i) ~= 0 && vert(i-1) == 0 && vert(i+1) == 0)
row(j) = i;
row(j+1) = i;
j = j + 2;
elseif((vert(i) ~= 0 && vert(i-1) == 0) || (vert(i) ~= 0 && vert(i+1) == 0))
row(j) = i;
j = j+1;
end
end
[temp column_size] = size (column);
if(mod(column_size, 2))
column(column_size+1) = cols;
end
[temp row_size] = size (row);
if(mod(row_size, 2))
row(row_size+1) = rows;
end
%%Region of Interest Extraction
%Check each probable candidate
for i = 1:2:row_size
for j = 1:2:column_size
% If it is not the most probable region remove it from image
if(~((max_horz >= column(j) && max_horz <= column(j+1)) && (max_vert >=row(i) && max_vert <= row(i+1))))
%This loop is only for displaying proper output to User
for m = row(i):row(i+1)
for n = column(j):column(j+1)
I(m, n) = 0;
end
end
end
end
end
end
0 Comments
Answers (1)
Walter Roberson
on 27 Jun 2017
You can use the author's Contact link to ask "why"
2 Comments
Walter Roberson
on 27 Jun 2017
We did not write the code. We would have to read the code thoroughly and research to figure out which technique was being used and how it is intended to work, and then compare to the actual code to figure out why the author choose those values. That would take a lot more effort than it would take you to contact the author through the author's profile page.
See Also
Categories
Find more on Scatter Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!