The way i did it is by looping over the matrix and counting number of black pixels in each row then comparing them ,the criteria i decided to go with for determing if a pixel is black is if the value of the pixel element is 20 or lower (i relied on this image to see which counts as a pure black pixel image).
is there a faster (less time complexity) way to do this ?
and are there any built-in functions in matlab that already do this?
row_blackPix = 0; % Number of the row with highest number of black pixels
black_count = 0; % Black pixel counter for a row
for i=1 : rows temp_blackCount = 0; for j=1 : cols if image(i,j) <= 20 temp_blackCount = temp_blackCount + 1; % Get number of blacks in row i
end end if temp_blackCount > black_count black_count=temp_blackCount; row_blackPix = i; end end
Best Answer