I have a 16 bit signed raw photo and would like to export this image as a tiff with ImageJ. The RAW photo is displayed correctly and the displayed value (172.00) is also correct. What does the value behind the 172.00 in brackets mean? When I export the image to Tiff, only this value (32940) is exported and the 172.00 no longer appears. How can I transfer this value into the Tiff? Or can the value in brackets be converted somehow?
Thanks a lot!
16-bit Signed RAW Photo with Temperature Values
This may have to do with the display range being different from the actual 16-bit pixel value (32940). ImageJ will display the images to you usually in the 0-255 range by default. In principle, the 32940 value should be the correct one to use for your analysis, unless you have an exceptionally dim signal for a 16-bit image. Check out the documentation here:
https://imagej.nih.gov/ij/docs/guide/146-28.html
Related
I am actually working with DCGAN (Py-Torch implementation), and the output is always a 64-sized grid of artificial images per epoch. I would like to increase such number, but do not know (I do not know which parameter to change, but I tried to check the code without success).
Does anyone have some idea of how to do that?
The entire Py-Torch implementation of DCGAN can be found in the following link:
https://pytorch.org/tutorials/beginner/dcgan_faces_tutorial.html
Change this value of below parameters to whatever the size of image you would want as output
Size of feature maps in generator
ngf = 64
Size of feature maps in discriminator
ndf = 64
I'm exploring Pixmap, and I have found Pixmap.Format with different formats and no discription:
Alpha
Intencity
LuminanceAlpha
RGB565
RGB888
RGBA4444
RGBA8888
What is the difference between them?
The relevant documentation is, unsurprisingly for a java library, in a totally weird place; specifically in docs for getPixels:
Returns the direct ByteBuffer holding the pixel data. For the format Alpha each value is encoded as a byte. For the format LuminanceAlpha the luminance is the first byte and the alpha is the second byte of the pixel. For the formats RGB888 and RGBA8888 the color components are stored in a single byte each in the order red, green, blue (alpha). For the formats RGB565 and RGBA4444 the pixel colors are stored in shorts in machine dependent order.
I've noticed that on some sites, a very low resolution version of an image gets displayed underneath the final version before it's done loading, to give the impression that the page is loading faster. How is this done?
This is called progressive JPEG. When you save a picture using a tool like Photoshop you need to specify you want to use this JPEG flavor.
I've found this Photoshop "Save for Web" dialog sample where you will find the whole Progressive option enabled:
What you are asking for depends upon the decoder and display software used. As noted, it occurs in progressive JPEG images. In that type of JPEG, the coefficients are broken down into separate scans.
The decode then needs to update the image in between decoding scans rather than just at the end of the image.
There was more need for this in the days of dial up modems. Unless the image is really large, it is usually faster just to wait and display the whole image.
If you are programming, the display software you use may have an option to update after scans.
Most libraries now use a model where you decode an image file stream into a generic image buffer. Then you display the image buffer. In this model, there generally is no place to display the images on the fly.
In short, you enable this by creating progressive JPEG images. Whether the image displays fading in dependents entire on what is used to display the image.
As an alternative, you can batch optimize all your images using the ImageMagick's convert command like this:
convert -strip -interlace plane input.jpg output.jpg
You can use these other options instead of plane.
Or just prefix the output's filename with PJPEG
convert -strip input.jpg PJPEG:output.jpg
Along with a proper file search or filename expansion (e.g.):
for i in images/*; do
# Your conversion command
done
The strip option is for stripping any profiles or comments, to make the conversion "cleaner". You may also want to set the -quality option to reduce the quality loss.
I am using an html5 canvas to render and image, do some basic editing of the image than trying to use the getImageData(0 function to read through the pixels and do some work. I have notices thou, no matter what bit depth the source image is (8 bit, 16 bit , 24 bit) the getImageData() method allows returns 8-bit (256 colors). this in not desirable. I would like the getImageData(0 method to spit out as many colors as it recieved.
I have read through the documentation and the canvas should be able to handle any bit depth you throw at it (figuratively) but I cant see anywhere to set the bit depth higher
Canvas will always return 24-bit data + an 8-bit alpha channel (RGBA). Each component value will of course have 8 bits or 256 values. This is per specification. It will never return 8-bit indexed image data however so if you somehow run into 8-bit (indexed) image data then you are probably reading the data wrong or from the from object/array.
From the specification:
imagedata . data
Returns the one-dimensional array containing the data in RGBA order,
as integers in the range 0 to 255.
And just to cover the opposite aspect: if you draw in a 8-bit indexed palette image such as a PNG-8 or a GIF using 2 - 256 colors their indexed palette will always be converted to RGBA buffer (it's actually converted to RGBA at load time by the browser so this is not something canvas do itself).
To read data from canvas you have two levels (or three for more advanced use), the image data object which contains various information including a reference to the actual pixel array view:
var imageData = context.getImageData(x, y, w, h);
From this object we obtain the data view for the pixels which is by default a Uint8ClampedArray view:
var pixelData = imageData.data;
And for more advanced usage we could get the raw byte buffer from this (if you need to provide other views, ie. Uint32Array) can be obtained from:
var rawBytes = pixelData.buffer;
var buffer32 = new Uint32Array(rawBytes);
But lets stick to the default 8-bit clamped view - to read from it you need to know that the pixels are always packed into RGBA or as 32-bit values. So we can get a single pixel by doing:
var r = pixelData[0];
var g = pixelData[1];
var b = pixelData[2];
var a = pixelData[3];
The next pixel will start at index 4 and so on.
If you for some reason need to reduce the palette to indexed palette you would have to provide the algorithm for this yourselves. There are many out there from simple and bad to more complex and accurate ones. But this is not something you will be able to do out of the box with canvas. Some pointers can be found in this answer or you can use a library such as this which will create a (animated) GIF from canvas.
Also be aware of that if an image drawn into canvas didn't fulfill cross-origin requirements (CORS) the canvas will be "tainted" (security-wise) and the getImageData() will return a an array with values set to 0.
ImageData (returned by getImageData) property data gives you an array in which each entry is a colour channel in sequence red, green, blue and alpha and not the actual colour. e.g.
red=imgData.data[0];
green=imgData.data[1];
blue=imgData.data[2];
alpha=imgData.data[3];
colour = '#' + (red<16)?'0':'' + red.toString(16) +
(green<16)?'0':'' + green.toString(16) +
(blue<16)?'0':'' + blue.toString(16);
In Flash I am able to create a font asset and add it to the library:
I want to convert this asset into some BitmapData that will contain all of the characters with the correct letter spacing/line height etc.
Is there an inbuilt way of doing this other than manually creating text fields, adding a character, using BitmapData.draw() and then adding the result to a sprite sheet?
If I need to do it manually like above, is there a way to retrieve all of the embedded characters? For example, in the above screenshot I'd expect only a-z, A-Z. Or will I need to note these manually as well?
If you're going to go with your own solution as I mentioned in my comment (like drawing out each supported character and then batching them together) then here is how you can look up every possible glyph supported by the embedded font. (Psuedo Code)
//Build out a loop that will generate char codes for all possible glyphs
for(etc, etc, etc) {
String glyph = String.fromCharCode(%26);
if(myFont.hasGlyphs(glyph) == true) {
myTextField.text = glyph;
myBitmap.draw(myTextField);
//Save image and repeat
}
}
Reference material:
List of supported char codes.
Font.hasGlyphs() documentation.
String.fromCharCode() documentation.