Finding pixel coordinates from pixel value

1 回表示 (過去 30 日間)
Avinash Bhatt
Avinash Bhatt 2019 年 5 月 25 日
コメント済み: Avinash Bhatt 2019 年 5 月 25 日
I am using the code as shown below to accquire the pixel coodinates of an image whose pixel value is below 80.
clc
clear all
close all
X=imread('cameraman.tif');
Y=rgb2gray(X);
for i=1:3
for j=1:3
if Y(i,j) < 80
[y z]=find(Y(i,j));
end
disp([y z]);
end
end
But my code is not working, it is showing the result as
1 1
1 1
1 1
Please help me in fixing this

採用された回答

Askat Kuzdeuov
Askat Kuzdeuov 2019 年 5 月 25 日
% there might some elegant solutions but as for now try to use this one
% prepare the desktop
close all; clc; clear;
% read the image
img = imread('cameraman.tif');
% obtain the size of the image
[row, col] = size(img);
ind = 0;
for ind1 = 1:row
for ind2 = 1:col
if img(ind1,ind2)<80
ind = ind + 1;
pix_cor(ind,1) = ind1;
pix_cor(ind,2) = ind2;
end
end
end
  1 件のコメント
Avinash Bhatt
Avinash Bhatt 2019 年 5 月 25 日
Thank You sir

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by