Removing saturated blocks of rows under pixel height
Posted: 2016-07-26T14:10:33-07:00
I assume ImageMagick can do this, but I have no leads in where to start.
I have this sample image:
I want to keep only the digits in the center of the image. Is there a way in IM, without writing things out to file, to remove the black bars at the top and bottom of the image? If I take the average grayscale value of each row, if fewer then X number of rows have a dark color, convert them to white. In other words, if a contiguous number of rows less than 30-pixels high have a darker average color, make the white. If there are more than 30 contiguous rows that have a darker average color, leave them intact.
Here is the output I'm going for:
I know I can, as someone recommended in another thread for a different question I had, resize down to 1 column wide to get average grayscale values, and then use those values in a script to perform the logic externally, but processing that way was very slow due to only processing one line at a time with IM.
Tips or ideas? Thanks!
I'm running ImageMagick-7.0.1-6 Q16-x64 on Windows (.bat) and 7.0.2-5 Q16-x64 on Ubuntu (.sh).
I have this sample image:
I want to keep only the digits in the center of the image. Is there a way in IM, without writing things out to file, to remove the black bars at the top and bottom of the image? If I take the average grayscale value of each row, if fewer then X number of rows have a dark color, convert them to white. In other words, if a contiguous number of rows less than 30-pixels high have a darker average color, make the white. If there are more than 30 contiguous rows that have a darker average color, leave them intact.
Here is the output I'm going for:
I know I can, as someone recommended in another thread for a different question I had, resize down to 1 column wide to get average grayscale values, and then use those values in a script to perform the logic externally, but processing that way was very slow due to only processing one line at a time with IM.
Tips or ideas? Thanks!
I'm running ImageMagick-7.0.1-6 Q16-x64 on Windows (.bat) and 7.0.2-5 Q16-x64 on Ubuntu (.sh).