Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
I scanned some books and randomly there are pages with a black border because of skewing in different sides of the page (probably because the page was not cut straight).
What i would like to do is either:
1.Automatically Color the black borders in white
2.Automatically Cut the black borders
I've attached an example showing the problem that i have.
should do: It corrects the angle by -deskew, then crops the page and extends it again, assuming that the borders of the page are, if not black, then more or less plain white. The code refers to the dimensions of your example.
Thank you. The problem is that the black border appear randomly and the width and position is randomly.In my opinion, first operation must be color in white the blackborder, and after that the deskew. But I dot know how to do.
There is an example somewhere in the forum
-bordercolor black -border 4x4 -fuzz "30%" -trim .....
but in my case is not working.
Magick.NET is listed as Imagemagick API at http://www.imagemagick.org/script/api.php. So in principle it should work. But I know little about any APIs. So cannot advise past command line concepts.
__________________________
Another way, is to average the image down to one row and analyze the profile to find where the black edges end and pure white starts. Or to find where the pure white ends and you have the text area. Then crop as appropriate and if desired pad back out with white. Using the image provided at the first post:
Another way, is to average the image down to one row and analyze the profile to find where the black edges end and pure white starts
Can you please clarify your idea? how to average the image down to one row? Is there a way with Magick.NET?
I simply need to calculate the black border width and height that is in the image and replace it with white border or crop it....
the command is as above, but probably better to use -scale
convert 28uibes.jpg -scale x1! image.txt
Once you have the 1 row image as text, you can filter for the color and coordinates. Then find the range of the pure white borders on the left and on the right and crop in the middle of the white borders (or on either the inside or the outside edge of the white -- anywhere is fine). Then pad back out to the original size if desired.
With the image above, there is black on the bottom. So what you probably need to do is find the max (near white) on the left and right, crop, then repeat with averaging to one column and do the same vertically.