How to apply a different b/w threshold to each row of the image?
9 views (last 30 days)
I would convert an image from grayscale to black-and-white using the im2bw function, and I need to apply a different threshold to each row of the image. Which is the most efficient way to do this? Is there a way to avoid the "for" cycle?
Thank you very much.
Andrew Bliss on 13 Jun 2016
Depending on the input type of your image, you may be able to just do a simple thresholding operation (as below), otherwise you'll have to delve a little deeper into image processing.
thresh=[50*ones(325,1);150*ones(325,1)]; %here you set the threshold for each row
More Answers (1)
Image Analyst on 14 Jun 2016
Edited: Image Analyst on 14 Jun 2016
No, you'll have to use a for loop. It's not a problem though. It will be very fast. No need to worry about for loops that are only a few thousand iterations.
Why do you need a different threshold for each row anyway?
You might be able to use a different function. There are new binarization functions. See Steve's blog: