Page 1 of 1
delete a line or two..
Posted: 2010-04-14T15:41:35-07:00
by toshog
hi all...
can somebody briefly explain what is the fastest way to delete the lines around the date and time in this image using the command line:
thanks...
Re: delete a line or two..
Posted: 2010-04-14T16:51:14-07:00
by snibgo
If you know the coordinates of the ends, IM could paint quickly over them. Finding those coordinates in the general case wouldn't be trivial.
Re: delete a line or two..
Posted: 2010-04-14T17:03:24-07:00
by fmw42
if this is a one-time thing, then it would be best to use a gui tool such as Photoshop or GIMP to paint over the lines with white.
Re: delete a line or two..
Posted: 2010-04-15T10:34:51-07:00
by toshog
snibgo wrote:Finding those coordinates in the general case wouldn't be trivial.
aware. thanks. any idea of how would that work?
Re: delete a line or two..
Posted: 2010-04-15T10:49:27-07:00
by snibgo
You'd have to examine a few examples to determine commonality. For example:
- Trim off surrounding white space.
- Is the date/time always in approximately the same position? Then crop everthing else away.
- Are the lines usually/always thicker than the letters? Then morphology erode will erode them first.
- Use "compare" to look for large patches of white space. This gives x-coordinates where the lines are not present.
Re: delete a line or two..
Posted: 2010-04-15T11:23:57-07:00
by fmw42
I tried morphology with no success.
Re: delete a line or two..
Posted: 2010-04-15T11:32:23-07:00
by toshog
thanks snibgo....
date and time a kinda in the same place but not really. sometimes not too close.
actually the lines are thinner then the letters.
i'll play with the compare you are mentioning although it seems to me like a long shot...
is there a way for imagemagick to detect anything else that is not a letter and that way get it's coordinates?
thanks...
Re: delete a line or two..
Posted: 2010-04-15T14:12:32-07:00
by snibgo
For this particular image, moo.jpg, IM can readily find the horiontal lines. Use a search pattern (say) 10 pixels wide, and six high. Make lines 0, 1, 4 and 5 white; lines 2 and 3 black.
compare -metric RMSE moo.jpg search.png found.png
Threshold found.jpg [edit: I mean found.png] about 66%, and it will be white where the search was found (ie the tops of the roughly horizontal lines) and black otherwise.
The vertical lines on moo.jpg aren't clean, so that technique wouldn't work there. Instead, you could find the limits of the white lines in found.png, and just assume the vertical lines are between those.
Re: delete a line or two..
Posted: 2010-04-15T15:17:53-07:00
by toshog
snibgo wrote:compare -metric RMSE moo.jpg search.png found.png
let me see if i understand this correctly. i need to create a search.png that has the same lines as they appear in the image? and then compare the two images to basically "cancel" out the lines in the main image?
if this is true i can try to do that. as a proof of concept but since these images would be scanned and maybe coming off cameras the box's dimensions may vary. maybe not drastically but enough to trow the comparison off..
does this make sense?
Re: delete a line or two..
Posted: 2010-04-15T15:32:11-07:00
by snibgo
Yes, that's it. That's why you need to find commonalities between source images. "compare" will find "similar" matches, hence my cut-off at 66% will finds lines that are shorter than 10 pixels, or are slightly diagonal, etc. Reduce that number to far, and you will get false positives.
If the input images vary greatly, you might need to change your strategy (eg search for diagonal or vertical lines).