Git Product home page Git Product logo

em-scalebartools's Introduction

EMScaleBarTools

Fiji macro toolset to quickly add a scale bar with reasonable size to an image. Developed for electron microscopy.

❗ Please double-check the scale-bar length for possible rounding errors, especially if it shows 1 µm, 1 nm, 1 mm, ... .

Example

Image source: Cropped image of Cobaea scandens (https://commons.wikimedia.org/wiki/File:Cobaea_scandens1-4.jpg) pollen by Marie Majaura from Wikipedia (https://en.wikipedia.org/wiki/Scanning_electron_microscope).

Examples

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).

Example

Using FEI Crop Scalebar on an SEM image.

Example

Batch conversion of SEM images (Process -> Batch -> Macro...) from tiff to png using FEI_Crop_Scalebar.ijm.

Example

Hotkeys can be used to quickly adjust the scale-bar appearance.

In-/Decreasing scale-bar length:
Basic usage

In-/Decreasing scale-bar size:
Basic usage

EMScaleBarTools in action

Examples are from v0.2.

Basic usage with cropping of a TFS/FEI databar, addition of a scale bar, moving and removing of the scale bar: Example

The next GIF shows the application of Auto re-scale images to upscale a small (in pixels) inset of an image: Example

The next GIF shows an example workflow when working with presentations (here Microsoft PowerPoint). For a horizontal alignment of images (here an SEM and an HAADF-STEM image) with the same desired image height, the scale bar reference is switched to Height. Note the automatic handling of unit-switching and rescaling as in the previous example. The image are then copied via the hotkey c to the system clipboard and pasted into PowerPoint. Example

Macro description

QuickScaleBar Tool (Icon: SB)
  • One-click action to add a scale bar to an image. Right click opens the options menu.

  • The scale bar height and font size is adjusted based on image height (or width).

  • The scale bar width is adjusted based on scaled image width (or height, or larger/smaller of the two) and rounded to next "good looking" number.

  • The scale bar appearance can be set up just like the normal settings for Analyze -> Tools -> Scale bar....

  • Optional: 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.

  • Optional: Automatically re-scale image to (at least) a specified image size in pixels without interpolation (= nearest neighbor interpolation). This is convenient for programs like PowerPoint which like to automatically interpolate "small" images.

  • Optional: Run custom macro commands provided in the options menu, e.g. run('mpl-viridis'); to change LUT to viridis.

FEI Crop Scalebar Tool (Icon: FEI)
  • One-click action to crop away the databar from an FEI/TFS SEM/FIB image and to add a scale bar. Right click opens the options menu.

  • Scale bar behaviour is the same as for QuickScaleBar tool and settings are taken from the QuickScaleBar options.

  • Optional: Run custom macro commands provided in the options menu, e.g. run('mpl-viridis'); to change LUT to viridis.

  • Especially useful for batch conversion of SEM/FIB images (run from Process -> Batch -> Macro... ): In the batch processing menu insert the macro command runMacro('FEI_Crop_Scalebar.ijm');.

For a description of the other tools, take a look at the wiki. 🗒

Requirements and Installation

  • Cropping the FEI/TFS info bar requires the useful EM tool plugin by IMBalENce as FEI/TFS images are scaled with SEM FEI metadata scale. Install via the Fiji update site.

  • Download the latest release, extract the macros folder, and copy it to your Fiji installation folder. It will add theFEI_Crop_Scalebar.ijm macro to the macros folder and the EMScaleBarTools.ijm toolset to the macros/toolset folder.

  • Restart Fiji and select the EMScaleBarTools from More Tools... (>>) menu.

Other useful scalebar tools

Citing

If you want, you can cite this project via Zenodo:

DOI

em-scalebartools's People

Contributors

lukmuk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

em-scalebartools's Issues

Calculating a 1-2-5 series

Lukas, thank you for this excellent tool!

I recently did my own macro for automatic scalebars, but very rudimentary and not so user friendly :) I would just like to share with you a piece of code that calculates the scalebar length in nice numbers: it calculates a 1-2-5 series until it reaches 1/10th of the image, perhaps it would be useful.

Cheer, Ales

// Add scale bar to image in 1-2-5 series size

// set the appearance of scalebar
scalebarsettings = "height=10 font=24 color=White background=None location=[Lower Right] bold overlay"; 
scalebarsize = 0.1; // approximate size of the scale bar relative to image width

getPixelSize(unit,w,h);
if (unit == "pixels") exit("Image not spatially calibrated");

imagewidth = w*getWidth();  // image width in measurement units
scalebarlen = 1; // initial scale bar length in measurement units

// recursively calculate a 1-2-5 series until the length reaches scalebarsize, default to 1/10th of image width
// 1-2-5 series is calculated by repeated multiplication with 2.3, rounded to one significant digit
while (scalebarlen < imagewidth * scalebarsize) {
	scalebarlen = round((scalebarlen*2.3)/(Math.pow(10,(floor(Math.log10(abs(scalebarlen*2.3)))))))*(Math.pow(10,(floor(Math.log10(abs(scalebarlen*2.3))))));
}

run("Scale Bar...", "width=&scalebarlen "+scalebarsettings);

Sort and split README

Sort and split the readme into serveral parts, currently it is very crowded and hard to read/navigate.

Reorganization of macro code and new features

For a new version (0.2) I plan on updating and reorganizing the code and new features.

Reorganization

  • The current version 0.1 calls macros from another toolset macro. Instead, we can combine the code into a single file?
  • Make FEI_Crop_scalebar take the arguments from QuickScaleBar tools. Currently, scale bar settings are split.
  • Maybe add a batch conversion action tool directly to the code, so users do not need to use Process -> Batch -> Macro...

Features

  • Add real option menus, instead of code editing, for easier use. Put all options there.
  • Add options for scale bar size scaling based on height, width, or the larger one of the two.
  • ... (Lets see what also is useful).

Rounding errors using numpad hotkeys

When using Numpad 4 and 6 to change scale-bar size rounding errors appear for scale bar lengths < 1.
As a result, 1 µm looks the same as 0.5 µm, since the latter is rounded to 1 for the scale-bar display.
Scale-bar lengths below 0.5 show "0" as scale-bar length.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.