We are analyzing seismogram traces on archival (micro-fiche) data that has been scanned to large images (15.5K x 600K px on average). Here is a 600px wide example:
The original is:
http://backspaces.net/temp/011868_1456_0123_04.png
and a 1000px wide version is
http://backspaces.net/temp/011868_1456_0123_04.1000.png
Our first task is to identify the center black area with white traces (i.e. get the x,y coords of the corners), then rotate (to x,y axes) and crop (to just the black trace area) so the images are "normalized" for further processing (finding the traces center lines!)
We probably will use smaller versions of the roughly 40MB lossless png's we're working with (original data is TIF, 90-100MB), I think identifying the corners on a smaller version should scale up with little additional processing within the larger image.
So the question is: is there an easy way to do this in IM? Its fine to go through several steps and create several images in the processing pipeline.
Thanks!
-- Owen
Seismogram preprocessing
-
- Posts: 3
- Joined: 2013-10-17T09:38:51-07:00
- Authentication code: 6789
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Seismogram preprocessing
For the first problem, rotating the image, I notice that the traces are not parallel to the edges of the black rectangle. I assume you want the traces horizontal. This Windows command returns the required rotation.
Get the result in a script. For your file, it is "-1.34262" (degrees).
Cropping down to the black is harder.
Code: Select all
convert ^
011868_1456_0123_04.1000.png ^
-gravity center -crop 50%%x50%%+0+0 -contrast-stretch 5%%,5%% -deskew 40 ^
-format %%[deskew:angle] ^
info:
Code: Select all
convert 011868_1456_0123_04.1000.png -rotate -1.34262 s.png
snibgo's IM pages: im.snibgo.com
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Seismogram preprocessing
The following trims to the main black rectangle.
It isn't perfect. It leaves a black mark top-left, and introduces spurious white top-centre and bottom-left.
It could easily be combined into a single command.
To convert my Windows scripts to Unix etc:
1. Change every "^" to "\".
2. Escape parentheses: change "(" to "\(" and ")" to "\)".
3. Windows needs to escape "%" but Unix doesn't, so change every "%%" to "%".
Code: Select all
convert ^
s.png ^
-threshold 85%% ^
-write mpr:ORG ^
( +clone ^
-negate ^
-morphology Erode rectangle:400x1 ^
-mask mpr:ORG -morphology Dilate rectangle:400x1 ^
+mask ^
) ^
-compose Lighten -composite ^
su.png
convert ^
s.png ^
( su.png -negate ) ^
-compose Lighten -composite ^
-fuzz 20%% -trim ^
sv.png
It could easily be combined into a single command.
To convert my Windows scripts to Unix etc:
1. Change every "^" to "\".
2. Escape parentheses: change "(" to "\(" and ")" to "\)".
3. Windows needs to escape "%" but Unix doesn't, so change every "%%" to "%".
snibgo's IM pages: im.snibgo.com
-
- Posts: 3
- Joined: 2013-10-17T09:38:51-07:00
- Authentication code: 6789
Re: Seismogram preprocessing
Oops, forgot to include a histogram of the scanned images:
They certainly are noisy in the black, and the traces are faint, I believe the dual spikes on the high end is caused by the edge of the images, which have bright whites with seismograph metadata, are brighter than the traces themselves.
-- Owen
They certainly are noisy in the black, and the traces are faint, I believe the dual spikes on the high end is caused by the edge of the images, which have bright whites with seismograph metadata, are brighter than the traces themselves.
-- Owen