ImageJ TIFF import image dimensions? - imagej

I have a bunch of auto-scanned slides using a slide scanner (Hamamatsu), which I can export from the NDPview software at different magnifications. So far, I have been zooming in to where I get the best resolution of my region on interest and add a scale bar for 1mm (as 1000 um) using the native scale bar option in the NDP view software. I then export the "view" from NDPview to TIFF. This TIFF is then imported into ImageJ (Fiji) where I set the scale using the scale bar I drew. This has been working well, but with over 500 images to do it's a bit of a pain.
Since the TIFF imports to ImageJ with inchxinch dimensions, I figured I can go to Image -> Properties and just change the unit of length to um. To test this, I selected an area to measure. I then compared this to my old method... and the values are completely different. Any idea why? 1 is the old method, 2 is the new method.
I made certain to "remove scale" in the scale bar window between each test. The whole image dimensions are different too:

If the images are all the same magnification and resolution, then as long as you know a measured distance (in pixels) and the physical distance (in microns or mm), you can set it using Analyze > Set Scale...
To do this in a macro you can use
run("Set Scale...", "distance=255 known=1 pixel=1 unit=micron");
where 255 is the distance in pixels for your known unit (1 micron). This can be applied to all TIFFs in a folder if you wrap that line in a loop operating on all TIFFs and save each resulting image.

Related

Set Pixelratio in Gimp to 0.5mm x 0.75mm

I have to paint some pictures for a small display of a micro controller. The Display has a resolution of 128x64 Pixel. But the Pixel aren't a square. They have a width of 0.5 mm and a height of 0.75mm. All my nice drawn images in GIMP look ugly on this display.
Can i change the ratio of drawn pixel in GIMP so i can see the image the same way like on my micro controller screen? Is there a setting for this or do i need to use my imagination?
I've looked around in settings menu but found nothing ...
thx in advanced
PS: Wrong Network?
Use Image>Print size to set a different definition for the vertical and horizontal axis (don't forget to "unlink" the two entry fields otherwise changing one will change the other).
Then untick View>Dot for dot so that Gimp no longer maps image pixels to screen pixels and displays the images with their intended definition (and aspect ratio in your case).

Gimp exports: Why is the image size increased?

I'm trying to use a two step process of employing Gimp to delete sections of images and then using Inkscape for the remainder of the image work.
Unfortunately, I'm seeing a resolution change when doing the export to PNG from Gimp.
The exported image is around 50% larger than the original, which impacts the quality.
Is there a way to keep the resolution constant when exporting the file?
Hopefully I'm just forgetting something, since I've spent some time away from image work.
Please let me know if any additional info is required.
In the interim, I'll try another tool to do the Gimp step.
THANKS!
Edit: Updated size to resolution.
For a bitmap/raster image, resolution (for Gimp: "Image print resolution", see Image>Print size) is indicative. The only thing that counts is the size in pixels.
If you have image window set to "Dot for Dot" (Edit>Preferences>Image Windows->General>"Use dot for dot" or View>Dot for dot) the image is displayed with the definition of your screen (around 100PPI fore regular screens, 20OPPI for high def ones (Retina, etc...).
When you create the image (File>New...), you can specify a print definition and a print size, and Gimp will compute the required size in pixels.

supplying the right image size when not knowing what the size will be at runtime

I am displaying a grid of images (3rows x 3 columns) in collection view. Each image is a square and its width is determined to be 1/3 of collectionView's width. Collection view is pinned to left and right margin of the mainView.
I do not know what the image height and width will be at runtime, because of different screen sizes of various iPhones. For example each image will be 100x100 display pixels on 5S, but 130x130 on 6+. I was advised to supply images that exactly matches the size on screen. Bigger images often tend to become pixelate and too sharp when downsized. How does one tackle such problem?
The usual solution is to supply three versions, for single-, double-, and triple-resolution screens, and downsize in real time by redrawing with drawInRect into a graphics context when the image is first needed.
I do not know what the image height and width will be at runtime, because of different screen sizes of various iPhones. For example each image will be 100x100 display pixels on 5S, but 130x130 on 6+
Okay, so your first sentence is a lie. The second sentence proves that you do know what the size is to be on the different screen sizes. Clearly, if I tell you the name of a device, you can tell me what you think the image size should be. So, if you don't want to downscale a larger image at runtime because you don't like the resulting quality, simply supply actual images at the correct size and resolution for every device, and use the correct image on the actual device type you find yourself running on.
If your images are photos or raster type images created using a raster drawing tool, then somewhere you will have to scale the original to the sizes you want. You can either do this while running in iOS, or create sets up front using a tool which can give you better scaling results. Unfortunately, the only perfect image will be the original with everything else being a distortion of the truth.
For icons, the only accurate rendering solution is to use vector graphics. Tools like Adobe Illustrator will let you create images which you can scale to different sizes without losing clarity. Unfortunately this still leaves you generating images up front. You can script this generation using most tools and given you said your images were all square, then the total number needed is not huge. At most you need 3 for iPhone (4/5 are same width, 6 and 6+) and 2 for iPad (#1 for mini/ipad1 and #2 for retina).
Although iOS has no direct support I know of for vector image rendering, there are some 3rd party tools. http://www.paintcodeapp.com/ is an example which seems to let you import vector images or draw vector images and then generate image code to run in your app. This kind of tool would give you what you want as the images are now vector drawings drawn at the scale you choose at run time. $99 though.
There is also the SVGKit (https://github.com/SVGKit/SVGKit), but not sure how good/bad this is. It seems to let you simply load and render direct from SVG files. Might be worth trying.
So in summary, I think you either generate the relatively small subset up front using a tool you can control the output from, take the hit in iOS and let it scale the images or use a 3rd party vector to image rendering kit which would give you what you want.

How to get rid of empty transparent areas in a PNG image so that it conforms to actual image size?

I have a series of images that I would look to loop through using iOS's [UIView startAnimating]. My trouble is that, when I exported the images, they all came standard in a 240x160 size, although only 50x50 contains the actual image, the rest being transparent parts that are just taking up space.
When I set the frame of the image automatically using image.size.width and image.size.height, iOS takes into images' original size of 240x160, so I am unable to get a frame that conforms to the actual parts of the image. I was wondering if there is a way using Illustrator or Photoshop, or any other graphics editing software for me to export the images based on their natural dimensions, and not a fixed dimension. Thanks!
I am a fan of vector graphics and thinks everything in the world should be vector ;-) so here is what you do in illustrator: file - document setup - edit artboards. Then click on the image, and the artboard should adjust to the exact size. You can of course have multiple artboards, or simply operate with one artboard and however-many images.

Interface building - UIViews vs Images vs Core graphics vs PDF subclass

My app uses flat graphics, which mostly consists of lines and flat surfaces...
Whats the best approach for building the UI?
use PNG images as much as possible (like for the attached picture, the whole background would be an image)
use 4 UIViews (in this example case) with background color to make the background and the 3 lines
use CoreGraphics to actually draw in drawRect (or somewhere else?)?
subclass UIView and draw PDF content
any other approach?
What are the performance impacts? The advantage of the first two, is that they can be done in IB, but is there a downside (like performance or quality or caching)? I also heard of a trend of using CoreGraphics for drawing all the time...
So basically the fastest way is to use PNG files (stretchable and normal), also if you are using PNG files it will be easy to change the design and fix eventual bugs.
When you are using PNG files, try to reduce the size of the PNGs (stretchable images for backgrounds) for a better performance and a small size of the app.
CoreGraphics is more complex and can add strange bugs or performance problems if you don't know what you are doing, but can be use also for simple view styling.
On every project that I've done I couldn't use only one of these two because of the project complexity or because I was to lazy to open photoshop and add extract some designs.
As H2CO3 said is not that simple. Each format suits particular requirements, there are no written laws, I just ca tell you what I do.
Small pieces of UI, such as buttons, icons etc: I normally use PNG or PDF. You can subclass a UIView to draw PDF vector content. The plus with PDF is that if the source is a vector image, you could not take care about physical-logical points.
Images or Hi-res images, such as image of a content: In this case I use JPG, for they small size respect of PNG. They take little bit more to decompress but usually the size is very smaller compared to PNG.
In general PNG can use alpha, JPG no
Image is a big topic, nowadays I always try a way to find symmetry in UI elements and use stretchable UIImages with PNG.
For you example I will use PNG witch stretchable left and right side. Instead of use 640 px image, you can use 10 px image, with stretchable right margin and stretchable left margin.
[update]
It should be said that if you use stretchable images you will get a lot of performance boost, since the image will be smaller, you will occupy less memory on the "disk", less memory on the heap thatnks to the GPU stretching and less decompressing times
.

Resources