What kind of encoding format is this to encode Jpeg image? - encoding

I have been working on Traffic sign detection. I found a github repository that is useful. There is a gtsdb3_train.record file contains training images. When I read gtsdb3_train.record file, I found encoded images looks just like this:
Encoded feature
image description 1
image description 2
I have to decode this encode to view training image, so I can train the model with my own image data.
Note: Here is the repository for Traffic Sign Detection: https://github.com/aarcosg/traffic-sign-detection

Related

Flutter: Efficient Image filtering

So I am using Dart's image package to manipulate an JPG image which was loaded and decoded.
Filtering the image works perfectly fine, however, display the image seems to be somewhat slow.
The idea was to use Flutter's Image widget in combination with a MemoryImage a la:
Image.memory(bytes)
bytes must be a binary representation of the image, e.g., PNG, JPG etc. and is not compatible with the image library's internal uint32 storage format or a simple bitmap. As a result, one is required to encode the bitmap back to a JPG which is pretty slow.
Is there a more efficient way of doing this?

How to load DICOM pixel data in browser preserving HU values?

I need to display the DICOM images in a browser. This requires, the DICOM to be converted to PNG (or any other compatible) format.
I also need to calculate some overlay pixels based on dynamic input from the user. On conversion to PNG, I am getting 4 values (Alpha, R, G, B). But I can not use these values for my calculations. I need the original HU values from the DICOM images.
Is there any way that, PNG can contain the original DICOM values. I heard that using monochromatic 16 bit PNG format it is possible. How do we do that?
Alternatively, how to load DICOM pixel data in browser preserving HU values?
When you convert DICOM pixel data to other non-DICOM format like PNG, BMP, JPG, J2K etc., the data you are looking for is lost. You may further research for TIF format whether it preserves the data and it loads in browser. I guess it will not.
I will recommend to avoid this way. Instead, I will suggest using DICOM pixel data as-is in browser. This can be achieved by involving some java-script DICOM toolkit for browsers like cornerstone. You may also look for other toolkit if available and suits you.
Note that this involves learning curve. It will be too broad here to explain its working.

Artifacts appear using imread function from opencv

I use imread function to read one jpeg file and save the rgb image in bmp format. Comparing the two files, I found artifacts appear and use green circle to denote artifacts. The version of OpenCV is 3.0. I compile the libraries by myself with SSE, SSE2 and SSE3 switchd on (default setting). My OS is windows 7 professional. You can use the following image to check.
original jpeg image
saved bmp file
If I read the jpeg file in Matlab, the rgb image is correct. I save rgb image in png format in Matlab, read the png file using opencv and save the loaded image in bmp file. Everything is OK. It seems that there is a problem with jpeg decoder. The jpeg library used is libjpeg.lib.
Due to the size limit, I cut the patch from the second image.
You're always going to get some artifacts in JPEG. You can reduce the appearance of such artifacts by changing the quantization tables used (usually with loss of compression).
JPEG encoders often use a "quality" setting to change the quantization tables.

PIL: converting an image with mode "I" to "RGB" results in a fully white image

The image at the end of this question is a PNG with mode I, which stands for Indexed, as far as I can tell.
I'm trying to create a thumbnail out of it, and save it as JPG with PIL.
However, is I leave the mode alone, PIL won't let me resize it with error unable to generate thumbnail: cannot write mode I as JPEG.
If I convert it to RGB, the result will be a fully white image.
Is there a way to fix this?
https://www.dropbox.com/s/2d1edk2iu4ixk25/NGC281.png
The input image is a 16-bit grayscale PNG, and it appears PIL has a problem with this. Manually converting it to an 8-bit image before further processing makes it work again.
The problem may originate inside PIL itself. The PyPNG homepage asserts
..PIL only has internal representations (PIL mode) for 1-bit and 8-bit channel values. This makes me wonder if PIL can read PNG files with bit depth 2 or 4 (greyscale or palette), and also bit depth 16 (which PNG supports for greyscale and RGB images).
Then again, that page is from 2009. It could be worth tracking down where PIL is maintained from, and report this as a bug (? Or possibly a feature request?).

Which type of data is returned by the following function?

Which type of data is returned by the following function?
CFDataRef CreateDatafromImage(UIImage *image)
{
return CGDataProvidercopyData(CGImageGetDataProvider(image.CGImage));
}
Binary image data
Raw pixel data
Compressed image data
ASCII image data
I guess the closest answer would be 2) Raw pixel data. Though, to be honest, I don't really see what the difference would be between Binary image data, and Raw pixel data. As for the third choice, Compressed image data, I suppose I could imagine how that could be referring to whether the NS/CFData object returned represents the compressed JPEG data (say, 100 KB) as it exists in the file, or whether it represents the data in its uncompressed form (say, 24 bit RGB, which might be 280 KB). In that case, I guess you could say that it represents the data in its "uncompressed" form.
But then, how exactly are you defining "compressed"? For example, say you have an image that is saved and has the following layout: 16 bits per pixel RGB, kCGImageAlphaNoneSkipFirst, like in the last example in this image:
Compared to the other layouts pictured, you could think of this layout as being "compressed" in some sense. (See Color Spaces and Bitmap Layout).
So, to sum up, by the time you've obtained a CGImageRef, the image is in a "native representation" that Quartz understands. The data returned from that method is the raw pixel data; the data isn't in "JPEG format", or "PNG format", or "TIFF format", etc. You can use the inquiry functions to gather information about what combination of image channels, alpha channels, and bit depth the image has: CGImageGetBitmapInfo(), CGImageGetBitsPerComponent(), CGImageGetBitsPerPixel(), etc.
Dealing with the image formats like JPEG, PNG, TIFF, etc. are abstracted into other APIs and types such as CGImageSourceRef, CGDataProviderRef, CGImageDestinationRef, and CGDataConsumerRef. See Moving Data Into Quartz 2D and Moving Data Out Of Quartz 2D.
Uh... A CFDataRef object?
The documentation is here: http://developer.apple.com/library/ios/#documentation/CoreFoundation/Reference/CFDataRef/Reference/reference.html
It's an object you can use as NSData or CFData interchangeably.
Internally a CFData is created (With the CGDataProvidercopyData) from the return value of the CGImageGetDataProvider call.
Good luck :)
It is covered in the docs (which is one of the first hits in Google).
This particular technical note covers it in detail.
http://developer.apple.com/library/mac/#qa/qa2007/qa1509.html