how to scan binary image and stop if value image=0
Show older comments
clear all; clc;
img = imread('asmfx.jpg');
[m,n,p] = size(img);
figure; imshow(img);
[xreg yreg value] = ginput(1);
title(['Row',num2str(xreg),'Col',num2str(yreg)])
if (length(xreg) < 1)

i want to snanning image with first set point with mouse like black rectangle. how can i scan up with row. and stop if value setpoint = 0. thanks before
return%break
end
%% inisialisasi posisi awal
sisiKanan = [xreg+10 yreg];
sisiTengah = [xreg yreg];
sisiKiri = [xreg-10 yreg];
%% scan tengah
markedTengah = insertMarker(img,[xreg yreg],'star','color','r','size',5);
for scanTengahY = xreg
for scanTengahX = yreg : yreg-100
%rr=[r(scanTengahX,scanTengahY),g(scanTengahX,scanTengahY),b(scanTengahX,scanTengahY)];
if scanTengahX == sum(cumprod(a~=0))+1
break;
markedTengah = insertMarker(img,[scanTengahX scanTengahY],'star','color','r','size',5);
imshow(markedTengah);
end
end
end
%marked = insertMarker(img,[xreg yreg],'star','color','r','size',5);
Accepted Answer
More Answers (1)
KSSV
on 12 Jun 2020
I = imread(myimage) ;
I1 = rgb2gray(I) ;
[y,x] = find(I) ; % this will gives points/ indices which have pixel value 1
imshow(I) ;
hold on
plot(x,y,'.r')
You can pick the matrix I1, and pick any column, and use find to know the positions if you want the first value when 1 starts.
3 Comments
Meizaki Fatihin
on 12 Jun 2020
KSSV
on 12 Jun 2020
When you click, you will get the indices...i,e (x,y)..you can get the respective row or column using
I(x,:)
I(:,Y)
From the row or column, you can use find, and get the indices of the pixel value you want.
meizaki fatihin
on 12 Jun 2020
is find () placed in the for loop function for scanning?
Categories
Find more on Image Arithmetic 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!