Is there any loss of information in converting jpg files to png? - deep-learning

I am working on an image dataset using deep learning for segmentation. The training images and masks are in jpg format. I would like to know whether there is any loss of information in converting jpg to png? I searched a bit, but couldn't get any relevant information. I am trying out whether using png images improves segmentation accuracy. Any help is appreciated.

PNG uses a lossless compression per default.
However, the PNG standard supports many different bit depths, color spaces and nifty features that can result in information loss. For example if you use a standard JPEG file with 24bit color and convert it to a PNG with 8bit color, you will lose image information.
When using default settings in libraries such as OpenCV or PIL, the conversion will be lossless though.

Related

Minimalistic way to read TIFF image format pixels

We are participating at the RoboCup 2015 from the German Aerospace Center in October. Before the torunament we will get a 30x30 pixel sized TIFF image, representing a low-pixel heigtmap. My task is to write a fast and lightweight, dependency free code that reads this TIFF image an does some algorythmic stuff on it.
I googled about the TIFF image format and it seems there are some powerfull libraries, but is there a simple way of reading just the color values of the file?
I remember a format, don't know which, where I just skipped the first 30 bytes and then could read the color values in RGB. Do you have any code that could do that or an idea/explanation how I could acchieve that?
As I said, I do not need filename, imagesize data etc. I actually don't even know why they have choosen the TIFF image-format since its just a normal heightmap in greyscale, but however.
Every help is very appreciated.

How to convert jpg or png images to dicom format in Lazarus?

The question is clear, How to convert jpg or png images to dicom format in Lazarus?
There are several commercial libraies which support DICOM file format. Or you can build your own.
Basically DICOM is a container. Images withing this containers can have a lot of different formats, including simple RGB raw image (that is 3 bytes per pixel, one for each primary color). The container also contains metadata. This can mostly be fixed. The only exception is image size.
There are plenty of DICOM resources on the web. Google is your friend.

What image file formats support storing binary images (1bit black and white) for display in Web Browsers?

I know TIFF and BMP do and PNG doesn't. I'm planning to use this file format to store images that in turn will display on a web page via normal directly. I don't plan to alter them with filters on the client side.
What will work for this scenario?
https://en.wikipedia.org/wiki/Group_4_compression
This link says that there are many standard and proprietary image formats that support storing these kind of images but doesn't say which exactly.
PNG certainly supports 1bit B/W images, either as gray or as indexed.
If what you want is some image format that is standard for web pages and that uses internally the same compression algorithm as CCITT Group 4 compression, then, no, you are out of luck. But why would you want that?

Optimal configuration for Tessnet -- is image format conversion good enough?

I need to do OCR on a group of images. I have been using Tessnet and it works pretty well. The problem is that it seems to have problems with some images, so I thought that it might work better if I modify the images' brightness, contrast, etc. Also, the images are in .jpg format, but I read that .tiff is optimal.
What can I do? Should I just convert the JPEGs to TIFFs?
There's no point in converting the jpeg images to a lossless format like tiff, you will convert the artifacts as well. You could try and apply a sharpness kernel on the image before you try to do ocr on it.
Look at this page for more information.

What image type should I use when? GIF, JPG or PNG? [duplicate]

This question already has answers here:
Closed 13 years ago.
I am trying to create a personal home page for myself to learn more about web design (JavaScript, using Photo Shop, etc). I plan on having a graphical menu on the left, a banner across the top and also a "Photos" section where I can display photos of various pictures I have taken.
However, when I look at other sites that do anything similar, I see some using GIFs, and some use JPGs and some even use PNGs. Is there any difference between these? Should I use a GIF for graphical images used on the site and JPGs for my photos? Should I make everything PNGs?
Exact Duplicate:
PNG vs. GIF vs. JPEG vs. SVG - When best to use?
Website Image Formats: Choosing the right format for the right task.
Which format for small website images? GIF or PNG?
PNG should be used when:
You need transparency (either 1-bit or alpha transparency)
Lossless compression will work well (such as for a chart or logo, or computer generated image)
JPEG should be used when:
Lossless compression will not work well (such as a photograph)
GIF should be when:
PNG is not available, such as on very old software or browsers
Animation is necessary
Despite myths to the contrary, PNG outperforms GIF in most aspects. PNG is capable of every image mode of GIF apart from animation, and when using the same image mode, PNG will have better compression due to its superior DEFLATE algorithm compared to LZW. PNG is also capable of additional modes that GIF cannot do, such as 24 bit color, and alpha transparency, but this is where you need to be careful: if you forget to convert to palette mode your PNG image may be saved in 24 bit color which will take more space.
PNG modes include (this is just a small subset)
Palette colour of 2 to 256 colors (like GIF)
Palette colour of 2 to 256 colors, with transparent color (like GIF)
True color (24 bit color)
True color with alpha channel (24 bit color + 8 bit alpha transparency)
For best compression in PNG for the web, use a palette mode. If you find PNG files are larger than the equivalent GIF files, then you're saving the PNG in 24 bit color and the GIF in palette mode (because a GIF is always in palette mode). Try converting to palette mode first.
PNG also has other modes such as palette color with alpha transparency. Modes such as this cannot be created in Photoshop, but other applications can create them.
Edit 2013: Removed a bunch of stuff about IE6 compatibility.
XKCD style comic strip that explains it:
http://lbrandy.com/blog/2008/10/my-first-and-last-webcomic/
Use JPG for photos and PNG for everything except photos. GIF is not really a very good format and PNG can replace it completely in compression and quality for most applications, but sometimes there are compatibility issues, not sure if these have been ironed out in all the current webbrowsers. GIF can be read by basically everything, so that's when it's very useful.
For buttons, icons, logos use PNG. Use GIF only if you need small animated images.
PNG can do all that GIF can (except animation, and even that is coming in APNG), and should almost always be smaller. If PNG isn't smaller than GIF, then your software may be saving it poorly - look for PNG optimisation progams, like PNGOUT and pngnq.
There are problems with GIF:
It only supports up to 256 colours.
It uses a patented compression algorithm.
But it does have an advantage:
It can be used to display an animation
JPEG can have a higher compression ratio than PNG/GIF but is lossy as the cartoon above demonstrates. It is best used for images where the compression artifacts aren't noticeable, photos for example.
Combining images into a texture and using CSS to unpack them will reduce the size slightly and reduce the number of server requests.
Depends on what you want to create. Typically, for your web graphics, go with PNG. For photos, JPG is fine. The 24-bit PNG supports alpha transpancy, so if you want to use "true color" alpha transparency that's your only option really. 8-bit PNGs are better and smaller than GIFs and also have pretty much the same transparency settings as GIF (an indexed color pallet) so there's no reason to use GIF anymore (unless you're making...gasp...animated gifs?). Remeber the the PNG format is lossless compression, so it will be nicer looking that a compressed JPG. One thing to keep in mind is that supporting PNGs in Internet Explorer 6 and below can be a pain, but there are many workarounds.
GIF - losless, small, but limited to 256 colors, and has one bit transparency (transparent or not)
JPEG - bigger, no small color limit, lossy. Best for photos.
PNG - losless, better transparency (alpha channel), but IE6 doesn't support alpha correctly, just with special fixes (fix here).
GIF is best for images with lots of solid colour - JPEG for images with lots of colour variance (EDIT: thanks, cletus). PNG is a newer format and often better than either JPEG of GIF - especially for screenshots.
See http://www.ou.edu/class/digitalmedia/articles/CompressionMethods_Gif_Jpeg_PNG.html
In general, jpeg is better suited for photos, while gif is better for graphic objects, like buttons or rendered letters.
png is good in both regards, but that discussion tends to get a little religious because there are license fees to pay if you develop a programm that reads/writes gif or jpeg, while png is free.
The difference is mainly in the compression, gif gets smaller file sizes for buttons, jpeg for photos.
My best advise is to play around with the different compression optioopns offered by all three formats and see for yourself which one you want to use for which purpose.
Oh, and because this is mainly about file sizes: See if you can test your homepage from a computer with a low bandwidth connection. That way you get a feeling if you need to worry about compression at all ;-)
Historically, GIF was here first, then JPG, then PNG.
GIF is very efficient for images with large areas of the same color (white background, for instance), because the RLL encoding compresses this well. However, GIF is patented technology (Unisys) and is seeing less and less use. Color depth is limited to 256 colors (I think).
JPG and PNG work well for most applications, but the files will be larger than GIF for very simple graphics. GIF can handle transparency and animations.
Edit: You are right - the patents expired on October 1, 2006.