Saving Crystal Centering Images and Video
Making still images and videos with the MacCHESS Crystal Centering Interface
David J. Schuller
The MacCHESS Crystal Centering Interface can save still images or a video
stream. A menu "Save Photos" appears along the top of the window. This
menu offers three options:
- Single Snap
- This option is for saving one image at the current settings.
- The image should be saved just as you see it, complete with crosshairs and
scale bar, if those are turned on.
- Clicking on the menu option brings up a file chooser.
- Specify a file name prefix. The complete file name will consist of the prefix + ".jpg"
and will be a JPEG image.
- Select the appropriate directory in which to save your image. The default should be the
data collection drive for your beamline (/A1a or /F1a) unless a previous user has changed it.
- Click "Snap!" and you're done. A "Success" dialog box should pop up, and you
can dismiss it. If you get a failure message instead, there is probably a
problem with the choice of directory, or with write privilege to the directory.
Image courtesy of Matt Warkentin of the Thorne lab.
- Multi Snap
- This option is for saving a series of still images of your crystal,
separated by PHI motor rotations.
- The images should be saved just as you see them, 1024x768 pixel resolution, complete
with crosshairs and scale bar, if those are turned on.
- A dialog box with file chooser should appear. Enter the appropriate values for the
number of images, the PHI increment between images, and the PHI starting value.
- Enter a filename prefix and select a directory in which to save the
- Click "Snap!" and you should see the PHI rotations being carried out,
followed by a "success" dialog box. Your image files will be saved with names
prefix###.jpg, where ### indicates the PHI rotation value for each image. (E.g.
test000.jpg, test090.jpg, test180.jpg, test270.jpg)
- A failure could be due to a problem moving the PHI motor, or a problem with the
directory being nonexistent or nonwritable.
This array of images was
scaled down and combined for convenience. Images courtesy of Matt Warkentin of
the Thorne lab.
- The video option is for saving a video stream, which is written as a MJPEG (Motion JPEG)
- The default frame rate at MacCHESS is set for 7.5 frames per second (fps). The
frame rate may be slowed down by fiddling with the camera settings in the "Cam"
panel at the lower right corner of the crystal centering interface; so if timing
is important, be sure to check the actual frame rate on the "Cam" panel before
recording your video.
- The images should be saved just as you see them, complete with crosshairs
and scale bar, if those are turned on; except that a time stamp is added
to the lower right corner.
- When you select the "Video" option a dialog box will appear.
- Choose the number of frames of video to be saved.
- Select the Frame Interval, for example save every frame (1 of 1) or one frame per minute
(approx 1 of 450, assuming the default frame rate of 7.5 fps). The number of frames and the
frame interval together determine the time span covered by the video.
- Select the file name prefix. The file will be saved as prefix.mjpg.
- Select the directory in which you want the file saved.
- Click "Snap!" and it will start working. The success dialog box will
appear after all the frames of video have been saved.
After the video file is saved, it can be viewed using the media player mplayer:
mplayer -loop 0 -fps 7.5 testvid.mjpg
"-loop 0" specifies that the video should be repeated endlessly.
"-fps 7.5" specifies a play rate of 7.5 frames per second.
Individual JPEG images can be extracted from the mjpeg file using ffmpeg:
ffmpeg -i testvid.mjpg -codec copy prefix%04d.jpg
"-i testvid.mjpg" specifies the input file. Substitute your own file name.
"-codec copy" specifies that individual JPEG frames will be extracted without alteration.
"prefix%04d.jpg" specifies the names of the output images, where "%04d" indicates 4
decimal digits (e.g. prefix0000.jpg, prefix0001.jpg, ...).
mplayer and ffmpeg are widely available on Linux. Other applications may be
available which can perform the same tasks.
If you need to reassemble individual JPEG images into a video, mencoder is an
application available on Linux which can do this. A couple example scripts are linked below.
Crystal of cytochrome bc1 courtesy of Ed Berry.
Sample scripts for image manipulation and video creation
- shrink.csh - script for scaling a set of
images with ImageMagick
- mencoder_gif.csh - script for creating an
animated GIF file using mencoder
- mencoder_mpeg4.csh - script for
creating an MPEG4 video using mencoder (Conveniently, MPEG4 will support a frame
rate of 7.5 fps)
Back to Schuller staff
MacCHESS home page