Page 1 of 2
Filter to improve some tif images
Posted: 2018-06-22T07:38:38-07:00
by Jean-Pierre Coulon
I have a tif image with many horizontal and vertical lines. When I zoom a horizontal line I often see irregular borders between the black and white areas. Translating this in .pbm this gives several full of zeroes, a line like 000001010010110011111 and several lines full of ones.
If I could transform the complicated line into 00000000001111111111 this would not affect the resolution of useful details but this would significally reduce the size ot the tif. Same request for a vertical line.
Of course a Gaussian-blur with sigma = 3 or 4 will do the job but it will blur useful details at other areas. Is there the right filter for me?
Re: Filter to improve some tif images
Posted: 2018-06-22T08:15:50-07:00
by snibgo
A sample image would help us understand the problem.
Re: Filter to improve some tif images
Posted: 2018-06-22T08:19:01-07:00
by Jean-Pierre Coulon
How can I attach a sample that is not on the web?
Re: Filter to improve some tif images
Posted: 2018-06-22T09:01:14-07:00
by fmw42
This forum does not allow uploads. So you need to post the image to some free image hosting service and then put the URL here. If your image is proprietary, can you create or find one that is not, which shows the same issue?
Also please always provide your ImageMagick version and platform? Perhaps you are using an old version and it needs upgrading or your delegate for the input or output format needs updating.
Re: Filter to improve some tif images
Posted: 2018-06-22T19:44:14-07:00
by Jean-Pierre Coulon
I hope an inline pbm does'nt spam this forum
P1
50 15
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 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0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
How can I cause Imagemagick to provide its version? It is not that I am obtaining an error message I don't understand.
Re: Filter to improve some tif images
Posted: 2018-06-22T22:31:50-07:00
by fmw42
will give you the ImageMagick version.
Re: Filter to improve some tif images
Posted: 2018-06-23T00:44:41-07:00
by snibgo
So, your image has noise. You want to remove the noise while not removing detail. From such a small sample I can't tell what is noise and what is detail.
However, the median filter cleans this image:
Code: Select all
magick lines.pbm -statistic median 11x1 out.png
Re: Filter to improve some tif images
Posted: 2018-06-23T02:43:28-07:00
by Jean-Pierre Coulon
fmw42 wrote: ↑2018-06-22T22:31:50-07:00
will give you the ImageMagick version.
hey, there is an old version in your brains
Here it works only with magick -version and it says 7.0.5-0 Q8 x86
Re: Filter to improve some tif images
Posted: 2018-06-23T03:25:45-07:00
by Jean-Pierre Coulon
snibgo wrote: ↑2018-06-23T00:44:41-07:00
So, your image has noise. You want to remove the noise while not removing detail. From such a small sample I can't tell what is noise and what is detail.
I would be happy if my 6th line was transformed into
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
However, the median filter cleans this image:
Code: Select all
magick lines.pbm -statistic median 11x1 out.png
Perfect for horizontal lines like my example, but does nothing for vertical lines and whitens some horizontal portions of vertical lines.
Re: Filter to improve some tif images
Posted: 2018-06-23T03:48:50-07:00
by snibgo
The median filter I show acts horizontally. If you want it to act vertically, interchange the dimensions: "-statistic median 1x11".
I suggest you post a link to entire images, not small portions.
Re: Filter to improve some tif images
Posted: 2018-06-23T17:39:25-07:00
by Jean-Pierre Coulon
You can obtain a test page like this: 1: scan 1 page of sheet music at 600 dpi, tif format, with an intentional skew of about 1 degree. Should be about 100 kB big. 2: say magick thispage.tif -deskew 50% newpage.tif. Should give an about 200 KB big page.
Magnify a portion of a staff line a lot and you will understand what I want to filter.
Re: Filter to improve some tif images
Posted: 2018-06-23T20:42:28-07:00
by fmw42
It would be better if you provide an example. This forum does not allow uploads. So you need to post the image to some free image hosting service and then put the URL here.
Re: Filter to improve some tif images
Posted: 2018-06-24T02:16:15-07:00
by Jean-Pierre Coulon
Then goto
http://imslp.org/wiki/Clarinet_Quintet_ ... g_Amadeus) Search the viola part in the Scanned by Coulonnus section. Extract p.2 with pdftk. Say magick p2.pdf -quality 100% -density 600 p2.jpg and magick p2.jpg -threshold 50% -compress group4 p2.tif (for some reason a direct pdf to tif conversion gives a result with a very low density). p2.tif should be 123 577 B big. But all it will contain will be a big number of cases like line 6 of my brief pbm example.
Re: Filter to improve some tif images
Posted: 2018-06-24T02:17:04-07:00
by snibgo
Jean-Pierre Coulon wrote:... scan 1 page of sheet music ...
Scanning makes continuous-tone images (grayscale or colour). But your image is black and white only. Why?
If you must make it black and white only, I suggest you do that
after denoising, not before.
Re: Filter to improve some tif images
Posted: 2018-06-24T06:14:04-07:00
by Jean-Pierre Coulon
snibgo wrote: ↑2018-06-24T02:17:04-07:00
Jean-Pierre Coulon wrote:... scan 1 page of sheet music ...
Scanning makes continuous-tone images (grayscale or colour). But your image is black and white only. Why?
Simply because a grayscale page would be about 10 times bigger than a monochrome. And the original document was monochrome.
If you must make it black and white only, I suggest you do that after denoising, not before.
Then is there the right filter for me in grayscale?
I succeeded in reducing the tif size by 75 % with my home made Fortran process.