|
| 1 | +# em-scalebartools |
| 2 | + |
| 3 | +Fiji macro toolset to quickly add a scale bar with reasonable size to an image. Developed for electron microscopy. |
| 4 | + |
| 5 | +## Examples |
| 6 | + |
| 7 | +Using QuickScaleBar on a HRTEM image. Note the similar size of the scale bars for the 4096² image (center) and the cropped 512² ROI image (right). |
| 8 | + |
| 9 | +<img title="Example 0" src="images/example0.png" alt="Example" data-align="center"> |
| 10 | + |
| 11 | +Using FEI Crop Scalebar on an SEM image. |
| 12 | + |
| 13 | +<img title="Example 1" src="images/example1.png" alt="Example" data-align="center"> |
| 14 | + |
| 15 | +Batch conversion of SEM images (``Process -> Batch -> Macro...``) from tiff to png using ``FEI_Crop_Scalebar.ijm``. |
| 16 | + |
| 17 | +<img title="Example 1" src="images/example2.png" alt="Example" data-align="center"> |
| 18 | + |
| 19 | +## Macro description |
| 20 | + |
| 21 | +##### QuickScaleBar Tool (Icon: <u>SB</u>) |
| 22 | + |
| 23 | +* One-click action to add a scale bar to an image. |
| 24 | + |
| 25 | +* The scale bar height and font size is adjusted based on image height. |
| 26 | + |
| 27 | +* The scale bar width is adjusted based on scaled image width and rounded to next "good looking" number. |
| 28 | + |
| 29 | +* Will automatically switch units to make scale bar more appealing: E.g. an image with horizontal field width of 0.25 µm will be switched to 250 nm. The scale bar will then also be in nm. |
| 30 | + |
| 31 | +##### FEI Crop Scalebar Tool (Icon: FEI) |
| 32 | + |
| 33 | +* One-click action to crop away the databar from an FEI/TFS SEM/FIB image and to add a scale bar. |
| 34 | + |
| 35 | +* Scale bar behaviour is the same as for QuickScaleBar tool. |
| 36 | + |
| 37 | +* Other image operations can be specified in the script (`process_image()` function). By default a simple "Auto Contrast/Brightness" contrast stretching is run. |
| 38 | + |
| 39 | +* Especially useful for batch conversion of SEM/FIB images (run from `Process->Batch->Macro...` ) |
| 40 | + |
| 41 | +* **Note:** The boundaries for the cropping area **depend on the microscope system type** because older FIB/SEMs use a nearly quadratic image format whereas modern microscope use landscape mode by default. You may need to adjust the microscope list once in the macro for your SEM, see instructions below. |
| 42 | + |
| 43 | +* |
| 44 | + |
| 45 | +##### Edit ScaleBarTools macros... Tool (Icon: ?) |
| 46 | + |
| 47 | +* Opens the Fiji code editor to quickly edit the macros for future use. |
| 48 | + |
| 49 | +* Adjust the scalebar looks here and add fancy image operations for the FEI Crop Scalebar Tool! |
| 50 | + |
| 51 | +## Requirements and Installation |
| 52 | + |
| 53 | +* Requires the useful [EM tool](https://imagej.net/plugins/imbalence) plugin by **IMBalENce** as FEI/TFS images are scaled with [SEM FEI metadata scale](https://imagej.net/plugins/sem-fei-metadata-scale). Install via the Fiji update site. |
| 54 | + |
| 55 | +* Download the latest [release](https://github.com/lukmuk/em-scalebartools/releases), extract the `macros` folder, and copy it to your Fiji installation folder. It will add the `QuickScaleTools.ijm` and `FEI_Crop_Scalebar.ijm` macros to the macros folder and the `ScaleBarTools.ijm` toolset to the `macros/toolset` folder. |
| 56 | + |
| 57 | +* Restart Fiji and select the `ScaleBarTools` from `More Tools...` (>>) menu. |
| 58 | + |
| 59 | +##### Add a new microscope system type |
| 60 | + |
| 61 | +Currently, only the system types `Helios G4 FX`, `Strata DB`, and `Quanta FEG` are implemented in `FEI Crop Scalebar`. You can add others in the following way: |
| 62 | + |
| 63 | +- Open a SEM/FIB image of your FEI/TFS machine. |
| 64 | + |
| 65 | +- Run ``EM tool->SEM FEI metadata scale`` and check the Log window for the system type: ``[System] SystemType : ScopeName`` |
| 66 | + |
| 67 | +- For images of different size (e.g. 4096 by Y, 2048 by Y, 1024 by Y, ...) check the cut-off point (pixel) between the image and the databar (zoom in). Add a new ``if`` clause to the macro similar to the ones already in the macro (starting with ``if(SystemType == ScopeName)``. E.g., for newer systems (`Helios G4 FX`) the cut-off is a power of two (512, 1024, ...) but for older scopes (such as ``Strata DB``) the values are more 'random' and you can simply specify a list with the cut-off values for different image sizes. |
| 68 | + |
| 69 | +## A short code documentation |
| 70 | + |
| 71 | +Warning: Code is not optimized in any way, but should work (?). :-) |
| 72 | + |
| 73 | +###### Scalebar looks: |
| 74 | + |
| 75 | +``sb_hfac``: Height of scale bar wrt image height in pixel (default: ``0.02``, 2% of image height) |
| 76 | + |
| 77 | +`sb_wfac`: Width of scale bar wrt image width (default: `0.2`, 20% of image width), will get rounded to next smaller "nice" value, see (``vals`` array in the code). |
| 78 | + |
| 79 | +`sb_fsfac`: Font size wrt `sb_hfac` (default: `2`, double of point size of scale bar height). |
| 80 | + |
| 81 | +`sb_col`: Font size color (default: ``'Black'``). |
| 82 | + |
| 83 | +`sb_bg`: Background color (default: `'White'`). Use ``'None'`` to remove background. |
| 84 | + |
| 85 | +``sb_loc``: Location/position of scale bar (default: ``'Lower Right'``). |
| 86 | + |
| 87 | +``U``: Unit switching factor (default: ``3``). Example: Will switch from µm to nm if image width is below 3 µm. Will switch from nm to µm if image width is larger than 3000 nm. |
| 88 | + |
| 89 | +###### QuickScaleBar |
| 90 | + |
| 91 | +``auto_rescale``: If true/1, automatically rescale (using no interpolation/nearest interpolation) small image width or height to at least ``rescale_target_px`` value. (default: ``0``, false). Useful to resize small cropped areas of larger images. This is the same as using ``CTRL+E`` and rescaling with ``Interpolation: None``. |
| 92 | + |
| 93 | +`rescale_target_px`: Target minimum pixel size for ``auto_rescale``. (default: ``800``) |
| 94 | + |
| 95 | +###### FEI Crop Scalebar |
| 96 | + |
| 97 | +``function process_image()``: Add image processing here, especially useful for batch conversion. (default: Auto C/B, i.e. ``run("Enhance Contrast", "saturated=0.35")``) |
| 98 | + |
| 99 | +## Other useful scalebar tools |
| 100 | + |
| 101 | +* Python: [matplotlib-scalebar](https://github.com/ppinard/matplotlib-scalebar) by ppinard |
| 102 | + |
| 103 | +* DM/GMS: [Scale Bar Control](http://www.dmscripting.com/scalebarcontrol.html) by D. R. G. Mitchell |
| 104 | + |
| 105 | +* Fiji/ImageJ: [asc-ImageJ-Fancy-Labels](https://github.com/peterjlee/asc-ImageJ-Fancy-Labels) by peterjlee |
0 commit comments