Steve on the Image Processing with MATLAB

Image processing concepts, algorithms, and MATLAB

Find all the highest pixel values using ismember

Today 's post shows how to use ismember 方便地定位图像中的所有像素值最高的。例如,在接下来的霍夫变换形象,什么是20值最高, Where are all the pixels that have those values ?
Hough transform - image. PNG
I got the idea from some example code written by Image Processing Toolbox writer Megan Mancuso. Megan says she got the idea to use ismember This way the from Ahmed 's answer On MATLAB Answers.
Here 's where the Hough transform image above comes from.
A = imread (“gantrycrane.png”);
Imshow (A)
Bw = edge (rgb2gray (A),"Canny");
Imshow (bw)
/ H, T, R = hough (bw);
imshow (H, [], XData = T, YData = R)
daspectauto
The axis
Now let 's sort to figure out the highest values of 20 H. .
Sorted_H_values = sort (H (:),"Descend");
Highest_H_values = sorted_H_values (1:20)
Highest_H_values = 20 x 1
293 250 209 205 182 177 173 172 171 168
Finally, I "l l use ismember To compute a binary image showing all the elements of H that have one of those 20 highest values. (And I "l l use xlim The and ylim To zoom in so that we can see what of those elements clearly.)
Mask_20_highest_values = ismember (H, highest_H_values);
Imshow (mask_20_highest_values XData = T, YData = R)
daspectauto
The axis
Xlim ([60] - 10)
ylim(452年[141])
Any element - wise logical function, to the as ismember , can be 2 in this way to produce a binary image, So add this to your bag of tricks MATLAB!
|
  • The print
  • Send E-mail.

comments

To comment, please clickhereLog in to your MathWorks account or create a new account.