Question
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);
Expert Answer
Kshitij Singh
PhD Expert
Answered Aug 27, 2026
[x,y] = ginput(1);
row = round(y);
column = round(x);
thisColumn = binaryImage(:, column); % Extract this one column from the binary image.
while row >= 1 && thisColumn(row)
row = row - 1;
end
When it's done, row will equal the row of the first 0 above the clicked point (which may be the clicked pint itself if you clicked on a black place). If you want the last white pixel before we hit black, add 1 to row. If row = 0, then there were no black pixels in the column above the clicked point.
100% Run Guarantee
3-Hour Fast-Track Delivery
Need a Custom Version or Complete Simulation for This Problem?
Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.
Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here
Related matlab Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →