* X-ray diffraction image --> .jpg [#v3e2d5ee]
回折イメージをJPEGなどに変換したい局面はちょくちょくあると思いますが・・・決定打は何かな?
- ''私も過去に検討したことがあるので参考ページ''
-- [[回折イメージを通常の画像にしたい>構造解析クックブック/07 発表準備#lb4004f2]] -- CCP4のDIFF2JPEGを使う方法
-- [[CCP4ライブラリを使う>Happy Scripting/CCP4ライブラリを使う]] -- CCP4のDiffractionImageライブラリを使う方法(上級者向け)
----
:質問|
ADSCの検出器で測定したX線回折イメージを標準画像形式(JPEGとかPNGとか)にするフリーなユーティリティはないかな?~
スクリーンキャプチャよりも高画質な画像が欲しいんだ。誰かは持ってると思うけど見つけられなかったよ。
- https://www.jiscmail.ac.uk/cgi-bin/webadmin?A2=ind0910&L=CCP4BB&D=0&T=0&P=187234
:回答|
- CCP4のDIFF2JPEGがあるよ -- 参考:[[回折イメージを通常の画像にしたい>構造解析クックブック/07 発表準備#lb4004f2]]
- MOSFLMでもできる。MOSFLM FAQをみてちょ -- http://www.mrc-lmb.cam.ac.uk/harry/mosflm/FAQ.html#movie
- MarViewってのもある -- http://www.marresearch.com/download.html#Utilities
- なぜLABELITを使わないのかなぁ?~
labelit.png <filename> <output.png> [-large]~
http://cci.lbl.gov/labelit~
- ImageMagickでできるんだ(後述)
- ADXVもあるぞ -- http://www.scripps.edu/~arvai/adxv.html
** ImageMagickで変換する by James Holton [#f7f7fdec]
ImageMagickの汎用データ読み込みで変換が可能なようです。さすがはJames Holtonといったとろですね。~
ImageMagickによる読み込みは応用できそうな予感。じっくり検証してみます。
- 出典 -- https://www.jiscmail.ac.uk/cgi-bin/webadmin?A2=ind0910&L=CCP4BB&T=0&F=&S=&P=196309
> Believe it or not, you can do this with ImageMagick, which is already part of most linux distros :
convert -depth 16 -type Grayscale -colorspace GRAY -endian LSB -size 3072x3072+512 GRAY:test_0_001.img test_0_001.jpg
where this example turns a binned Q315 image (3072x3072 pixels) with a
512-byte header (almost always the case) that has
"BYTE_ORDER=little_endian" into a jpg image. For a big_endian image,
you change LSB to HSB in the above command.
#br
You may notice that the image above compresses incredibly well (about
300 fold), but if you look at it, you will be very disappointed as it is
almost totally black. This is because JPEG only uses the high-order
byte of a 16-bit image. One could argue that this is perhaps the
"right" way to look at diffraction patterns since the most important
information is in the bright spots and not the noisy background, but if
you want to render your *.img file in the "ADXV way", then this command
is close:
convert -depth 16 -type Grayscale -colorspace GRAY -endian LSB -size 3072x3072+512 \
GRAY:test_0_001.img -negate -crop 1024x1024+512+512 -equalize test_0_001.jpg
The "-negate" flag will make the spots black and the background grey,
and the "-equalize" filter will throw out all the "outlier pixels"
(spots) so you can look at the background. You may also want to use the
"-crop" option to focus in on just one part of the image. There are
other "enhancement" flags like -normalize, and -contrast-stretch or -brightness and -contrast, but the exact behavior of these flags will depend on the version of ImageMagick you have.
#br
There is probably also a way to "colorize" the data the way ADXV does
with the "heat" or "rainbow" options, but I don't know how to do that in
ImageMagick. In such cases, I do use screen capture, but again
ImageMagick's "import" program is convenient for this. Coupled with the -autoload flag in ADXV, you can set the environment variable $XFORMSTATUSFILE to something like ./temp.txt and write a script to echo
"$n $filename" into this file (where $n is an ever-increasing number),
wait a few seconds (sleep 2), and then run "import -w root -crop ..." to
capture the screen and crop out the part you want.
#br
This will work for the formats supported by ADXV, but obviously other
formats will need another program. The central problem is that every
program (ADXV, MOSFLM, HKL, D*trek, etc.) has different ways of crushing
the 16-bit pixels into 8 bits for the display, and we all have our
"favorite" (the one that we think makes weak spots show up better), but
almost none of the GUI displays have command-line-with-options
equivalents. ImageMagick has enough features that you can usually
figure out how to "replicate" a given display program's algorithm, but
some file formats (like the "packed" Mar files) will never be readable
by ImageMagick.
#br
It is perhaps worth pointing out that the "ADSC format" is actually
called "SMV" since this file format was originally created about 30
years ago for a program called "Super Marty View", (written by Martin
Stanton, now at SomaLogic). It has evolved somewhat since then. The
taxonomy of image file formats is something of a hobby of mine. There
seems to be no less than a hundred different species of them floating
around in the world. Some are rare, some are locally prevalent, but they
appear to all be highly territorial and you will almost never find more
than one varietal populating a given lab, synchrotron or even a given
country. Someday I hope to collect specimens of each and every one of
them (perhaps even filling out the "fossil record" or history of
different beamlines and detectors) but documentation and particularly
"example lysozyme datasets" are surprisingly hard to come by. For
example, I once had a crinkly old paper document that defined the
"R-axis format", but recent sitings of files from R-axis detectors seem
to be a new species descended from an SMV-like ancestor, and yet nowhere
on the Rigaku website is there a document describing this new format,
much less an example. Most crystallographers do not have "good" data
sets on hand (it is the bad ones that stay on disk forever), and many
beamline scientists do not have any "test" data sets available either
(for some reason). Currently, my meager "museum" is here:~
http://bl831.als.lbl.gov/example_data_sets/ ~
If anyone would care to donate, I prefer data sets that are "easy" to
process and that have anomalous differences (to clarify the hand of the
spindle), but in cases where I have no examples, any data set will do.
#br
RIGHT:James Holton~
RIGHT:MAD Scientist