How to know the real row and column indices of a pixel in the image

4 ビュー (過去 30 日間)
Salad Box
Salad Box 2019 年 10 月 23 日
コメント済み: Salad Box 2019 年 10 月 23 日
Hi,
I have an image. See below.
>> fn = 'Unknown.jpg';
>> RGB = imread(fn);
>> whos RGB
Name Size Bytes Class Attributes
RGB 235x214x3 150870 uint8
>> s = size(RGB);
>> RGB = reshape(RGB, s(1)*s(2),3);
>> whos RGB
Name Size Bytes Class Attributes
RGB 50290x3 150870 uint8
After 'reshape', now 'RGB' becomes 50290 by 3.
I wonder that given a row index such as 37987 in the current form of RGB, how to find the corresponding pixel in the image and eventually draw a circle around that pixel on the image.
The main thing is to find the correspoinding pixel in the image.
I tried. However, the pixel I found is outside that image and is white as [255 255 255] which doesn't seems right at all.

回答 (1 件)

Walter Roberson
Walter Roberson 2019 年 10 月 23 日
which_pixel = 37987;
[r, c] = ind2sub([s(1), s(2)], which_pixel);
And remember that row corresponds to Y and column corresponds to X.
  1 件のコメント
Salad Box
Salad Box 2019 年 10 月 23 日
Fabulous!!!!
It worked perfectly!!! You saved my day!!! Thanks a million!!!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeImages についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by