Page 1 of 1

Seismogram preprocessing

Posted: 2013-10-17T10:41:04-07:00
by backspaces
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:

Image

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

Re: Seismogram preprocessing

Posted: 2013-10-17T11:07:20-07:00
by snibgo
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.

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:
Get the result in a script. For your file, it is "-1.34262" (degrees).

Code: Select all

convert 011868_1456_0123_04.1000.png -rotate -1.34262 s.png
Cropping down to the black is harder.

Re: Seismogram preprocessing

Posted: 2013-10-17T11:49:45-07:00
by snibgo
The following trims to the main black rectangle.

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 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 "%".

Re: Seismogram preprocessing

Posted: 2013-10-17T13:43:57-07:00
by backspaces
Oops, forgot to include a histogram of the scanned images:
Image

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