News for hackers. Stuff that matters.
Re:John Carmack on JPEG by Animats on Friday June 04, 2021 @06:33PM (#27399824)
There's JPEG 2000, which is nothing like classic JPEG. It doesn't have the artifacts classic JPEG introduces at sharp edges, so you can read text. It has more color depth if you want it. It also doesn't mess up non-color data such as normal maps the way classic JPEG does.

JPEG 2000 is not used much. Decoding is slow, and encoding is slower. The decoders are either buggy or proprietary. It has way too many options internally. The big users of JPEG 2000 are medical. It has a "lossless" mode, and medical imagery is usually stored lossless because you really don't want compression artifacts in X-rays.

(I've been struggling with JPEG 2000 recently. Second Life and Open Simulator use it for asset storage. Some images won't decompress properly with OpenJPEG, a free decoder. I finally found out why. There's a field used for "personal health information" in JPEG 2000. This is where the patient name and such go in a CAT scan. That feature was added after the original version. Some older images apparently have junk in that field, which causes problems.)

Re:John Carmack on JPEG by acdha on Friday June 04, 2021 @07:31PM (#27400328)
OpenJPEG has improved the situation a bit but I use JPEG 2000 as a cautionary example. The community had some good selling points but assume that meant inevitability and slacked off on browser compatibility, open source, and even interoperability. For the first decade or so you had to pay something like $1,500 to get a copy of the spec, too.

I work in the library/archiving space where people spent years trying to make this happen due to the compression wins, support for a good range of color depths and spaces, and the progressive decoding is perfect for browsing galleries of high-res images before zooming way into the one you wanted.

The frictional cost largely canceled that out: people don’t trust unreliable formats and the JP2 files which only opened in one of {Kakadu, Aware, Adobe} and couldn’t be used with any open source tools live long in the memory. Performance in Jasper was wretched … and while the vendors thought that’d boost sales, it seemed far more effective to me at getting people to use other formats instead.

These days, if anyone is talking about new image formats the first question is what they’re doing for open source (especially things like ImageMagick which half the world uses) and specifically browsers. A WASM polyfill for <picture> or <img srcset> is really critical because it means people don’t have to transcode everything for a handful of users.

Re:John Carmack on JPEG by matheusmoreira on Saturday June 05, 2021 @10:33AM (#27405376)
Proprietary stuff just isn't worth it. They erect so many barriers around the format and the specification that it's essentially impossible to get anything done.
Re:John Carmack on JPEG by radarsat1 on Saturday June 05, 2021 @12:25PM (#27406361)
This reminds me of Sony's minidisc technology. Such a cool product for its time but they purposely made it impossible to use and incompatible with everything.
Re:John Carmack on JPEG by matheusmoreira on Saturday June 05, 2021 @02:16PM (#27407350)
Sony UMDs too!
Re:John Carmack on JPEG by acdha on Saturday June 05, 2021 @11:29AM (#27405842)
That’s my general conclusion and it’s substantially more so for the library/archive case where long-term stability is so important. It’d be one thing if, say, a game found a format to be so much better when they control the encode and decode sides completely but once that’s not true it really needs a first-class open source implementation to even be considered.
Re:John Carmack on JPEG by TazeTSchnitzel on Friday June 04, 2021 @06:40PM (#27399881)
> Second Life and Open Simulator use it for asset storage

JPEG2000 is such a cool choice for Second Life. The fact any truncation of a JPEG2000 bitstream is just a lower-resolution version of the image makes for convenient progressive enhancement when loading textures over the network, right?

(And Second Life even used JPEG2000 for geometry, sort-of. I guess with the advent of proper mesh support, that may be less common now though.)

Re:John Carmack on JPEG by astrange on Saturday June 05, 2021 @01:41AM (#27402539)
JPEG itself has that property - you can decode any JPEG at 1/8 the size pretty easily, and progressive scan JPEGs do what you want here.

Dedicated texture compression formats would also do this since they use mipmaps, but I don't know if you can stream those.

Re:John Carmack on JPEG by boxerab on Saturday June 05, 2021 @11:25AM (#27405815)
For JPEG, if image is encoded using resolution progression, then decoder can not decode using quality progression (where image quality improves with each new piece of the image) and vice versa. With JPEG 2000, the decoder can decide which progression it wishes to use at decode time - by resolution, by quality, by component, or by spatial region.
Re:John Carmack on JPEG by muxator on Saturday June 05, 2021 @03:11AM (#27402912)
Anyway, progressive jpeg2000 decoding is more sophisticated than progressive jpeg
Re:John Carmack on JPEG by Something1234 on Friday June 04, 2021 @07:22PM (#27400247)
This is super interesting. Do you have any more details on the use of JPEG2000 for geometry? I would be curious to hear more.
Re:John Carmack on JPEG by raphlinus on Friday June 04, 2021 @07:37PM (#27400374)
Sculpted prim. The object was basically a mesh of triangles in a fixed configuration, but the coordinates of the individual vertices were derived from an image (compressed using lossless JPEG2000, as any compression artifacts, not to mention chroma subsampling, would cause really ugly distortion). This was a halfway point between allowing arbitrary meshes and only pre-made object geometries (but with skinnable textures).

http://wiki.secondlife.com/wiki/Sculpted_prim

Re:John Carmack on JPEG by supernintendo on Friday June 04, 2021 @08:17PM (#27400681)
It also seems like support for JPEG 2000 can be hit or miss. I tried to open a .jp2 file I downloaded from the web into GIMP, but it looks all funky.

Original image: https://www.fnordware.com/j2k/jp2samples.html

What it looks like in GIMP: https://imgur.com/a/HCNz7ga

Re:John Carmack on JPEG by ponyfleisch on Friday June 04, 2021 @09:42PM (#27401163)
And iOS Safari shows it as a mostly green mess. After tapping the image to get to the real .j2, in the page itself it’s a png.
Re:John Carmack on JPEG by supernintendo on Friday June 04, 2021 @10:19PM (#27401390)
Wow, I just checked and you're right. I find it fascinating that all of this modern software continues to support JPEG 2000 in such a buggy state. Or maybe it's the file itself that's corrupted? I don't know enough about the file format to say.
Re:John Carmack on JPEG by savoytruffle on Saturday June 05, 2021 @01:29AM (#27402480)
the file is obviously wrong
Re:John Carmack on JPEG by BlackLotus89 on Saturday June 05, 2021 @07:18AM (#27403992)
The file is correct. You can open it in imagemagick (display) to check. Could be a simple problem with the colorspace implementation of gimp or something similar. If you would read the comments you would know what a mess jpeg2000 implementations are
Re:John Carmack on JPEG by jasomill on Sunday June 06, 2021 @03:48AM (#27411500)
Something appears to be wonky with the ICC profile embedded in this image. And while I have no idea whether the file itself complies with applicable standards, I can say that ImageMagick is not a reliable test in this case. To wit:

1. Per Photoshop, "The embedded ICC profile cannot be used because the ICC profile is invalid."

2. After using the OS X Preview.app "Assign Profile" command to replace the embedded ICC profile with the system-supplied sRGB profile, the image displays correctly in Safari.

3. The ImageMagick display command is apparently ignoring the embedded profile and assuming sRGB, as it continues to display the image correctly even when I replace the embedded profile with an obviously incorrect (but valid and correctly interpreted by Photoshop and Safari) profile.

Re:John Carmack on JPEG by jmrm on Sunday June 06, 2021 @06:11AM (#27412045)
The same with ImageGlass, my default image viewer software in Windows
Re:John Carmack on JPEG by Izkata on Friday June 04, 2021 @10:53PM (#27401642)
Firefox (Ubuntu) wants to download it instead of display it...
Re:John Carmack on JPEG by Keyframe on Friday June 04, 2021 @06:38PM (#27399865)
JPEG 2000 is not used much

There's one big win though. Digital cinema projectors, in now pretty much all theatres, run DCPs which have movies encoded with it.

Re:John Carmack on JPEG by JacobiX on Saturday June 05, 2021 @07:27AM (#27404036)
We used it to compress scanned PDFs, using mixed raster techniques. Since the PDF natively supports JPEG2000 we used it for document background compression and we used JBIG2 for text image compression. The compression ratio was impressive but the document rendering was noticeably slower even with Adobe reader …
Re:John Carmack on JPEG by gsich on Saturday June 05, 2021 @03:22PM (#27407815)
>background compression and we used JBIG2 for text image compression

Are you aware of the downsides?

https://www.dkriesel.com/en/blog/2013/0802_xerox-workcentres...

It stands to reason that not only Xerox had problems with JBIG2.

Re:John Carmack on JPEG by JacobiX on Saturday June 05, 2021 @05:15PM (#27408506)
Thank you for the link, yes we are aware of this particular issue. For our engine we used only lossless mode and using this mode the decompressed binary image is identical to the original so the described problem cannot occur. Nonetheless this limit severely the usefulness of JBIG2.
Re:John Carmack on JPEG by aaron-santos on Friday June 04, 2021 @06:43PM (#27399915)
Adding to the list: ESA's Sentinel 2 products (granules/tiles) in are typically distributed in JPEG2000 format. Anyone working with this imagery has probably experienced all the trouble associated with extracting and transforming it into a more useful format.
Re:John Carmack on JPEG by superkuh on Friday June 04, 2021 @08:30PM (#27400780)
NASA's Solar Dynamics Observatory Atmospheric Imaging Assembly telescopes are available from various NASA and ESA servers as JPEG2000. The java software JHelioviewer (http://www.jhelioviewer.org/) displays these 4k*4K JPEG2000 files with opengl acceleration at high frame rates and it is beautiful.
Re:John Carmack on JPEG by alwillis on Friday June 04, 2021 @07:04PM (#27400090)
macOS and iOS have always supported JPEG2000.
Re:John Carmack on JPEG by PostThisTooFast on Saturday June 05, 2021 @04:55AM (#27403387)
Red Camera ripped off JPEG2000 to create its codec; now they extort every other camera vendor that wants to do compressed raw, thanks to the bullshit patent they were able to acquire on it.
Re:John Carmack on JPEG by user-the-name on Saturday June 05, 2021 @05:54AM (#27403634)
JPEG 2000 is ancient. It is nearly as old as JPEG itself, it long since missed it's change to become relevant. Today it is a legacy format and should be mostly ignored. It has its own types of artefacts, which in some cases are even worse for image quality than those of JPEG.

JPEG has introduced multiple new formats since JPEG 2000, all of which are better, such as JPEG XR and JPEG XL.

Re:John Carmack on JPEG by j16sdiz on Saturday June 05, 2021 @08:19AM (#27404282)
JPEG was designed in 1992 JPEG2000 was designed 1997-2000
Re:John Carmack on JPEG by moron4hire on Saturday June 05, 2021 @10:54AM (#27405558)
The year right now is 2021. So yes, JPEG 2000 is almost as old as JPEG.
Re:John Carmack on JPEG by Sebb767 on Friday June 04, 2021 @06:41PM (#27399891)
What's the advantage of JPEG2000 lossless over, say, PNG? Archives will probably be compress later on anyway and using a widely-supported and known format seems far more suited for archival purposes.
Re:John Carmack on JPEG by aaron-santos on Friday June 04, 2021 @07:00PM (#27400052)
JPEG2000 can be more of a data container than an image format. While the downsides are many, there are a few upsides to JPEG2000. Greater bit depth is useful when storing DNs. More than three channels is useful when storing multi-spectral images. Internal tiling is useful when range reading specific parts of an image (obvs more useful when working with very large images). These specifically make JPEG2000 more useful than PNG when working in certain domains. Satellite imagery is one such domain.
Re:John Carmack on JPEG by j16sdiz on Saturday June 05, 2021 @08:14AM (#27404258)
Why not just TIFF for container?
Re:John Carmack on JPEG by shakow on Friday June 04, 2021 @07:28PM (#27400296)
DNs?
Re:John Carmack on JPEG by hollasch on Friday June 04, 2021 @07:51PM (#27400498)
Digital Negatives
Re:John Carmack on JPEG by aaron-santos on Friday June 04, 2021 @07:32PM (#27400332)
Digital number, the output of an analog to digital converter.
Re:John Carmack on JPEG by gsich on Friday June 04, 2021 @07:40PM (#27400406)
I thought Digital Negative.
Re:John Carmack on JPEG by aaron-santos on Friday June 04, 2021 @10:04PM (#27401282)
I can see how it would be useful for digital negatives too, but I don't know much about those.
Re:John Carmack on JPEG by gsich on Saturday June 05, 2021 @09:34AM (#27404865)
It's a fancy word for raw files.
Re:John Carmack on JPEG by shakow on Friday June 04, 2021 @08:59PM (#27400934)
Thanks!
Re:John Carmack on JPEG by KMag on Saturday June 05, 2021 @04:18AM (#27403235)
> Archives will probably be compress later on anyway

What do you mean by this? Zip, 7zip, gzip, zstd, etc. get little to no compression on PNG. JPEG, or JPEG2000. Presumably you mean something other than zipping up directories of images.

Re:John Carmack on JPEG by josefx on Saturday June 05, 2021 @10:58AM (#27405593)
Zip compressing a single PNG is kinda redundant, since it already uses the same algorithms as part of its own lossless compression.
Re:John Carmack on JPEG by KMag on Saturday June 05, 2021 @11:08AM (#27405681)
Yes. I'm aware that zip, gzip, and PNG all use zlib DEFLATE compression.
Re:John Carmack on JPEG by boxerab on Saturday June 05, 2021 @11:19AM (#27405771)
The issue you are facing with OpenJPEG has nothing to do with PHR, (which isn't actually "personal health information"), but the fact that the library doesn't decode truncated images. The standard is designed for best-effort decoding when there are corrupt or missing packets, but the implementation errors out when it detects this.
Re:John Carmack on JPEG by jacobolus on Friday June 04, 2021 @06:36PM (#27399849)
Other big users of JPEG 2000 include libraries and archives storing e.g. historic map images.
Re:John Carmack on JPEG by lstodd on Friday June 04, 2021 @10:36PM (#27401520)
Ew, and some years ago I almost but not quite entirely rewrote pnglite exactly because med data has to be lossless, mostly grayscale, in tens of megabytes, and JPEG2000 doesn't even approach to cut it. Something like 10-20Mpix lossless grayscale, well, actually approaching good old xray photos.

What possesed someone to actually attempt to use JPEG2000 I do not understand.

Re:John Carmack on JPEG by yyyk on Friday June 04, 2021 @07:02PM (#27400067)
Technically, PDFs support JPEG 2000 though this isn't widely used.
Re:John Carmack on JPEG by userbinator on Friday June 04, 2021 @08:09PM (#27400625)
The eBooks on archive.org are probably the most well-known example. They take noticeably longer to display too, which was what lead me to discover that fact.
Re:John Carmack on JPEG by cma on Friday June 04, 2021 @09:41PM (#27401156)
Carmack's game Rage used JPEG XR I believe.
Re:John Carmack on JPEG by swiley on Saturday June 05, 2021 @09:37AM (#27404898)
>JPEG 2000 is not used much

Apple has decided it shouldn't be by not allowing its use on iOS.

Re:John Carmack on JPEG by gvb on Saturday June 05, 2021 @10:10AM (#27405173)
Someone on the internet says Apple iOS does support it: https://davidwalsh.name/how-to-use-jpeg-2000-jp2-for-a-faste...
Re:John Carmack on JPEG by PostThisTooFast on Saturday June 05, 2021 @04:53AM (#27403381)
Fun note: Red Camera ripped off JPEG2000 and of course got a patent on it through the USA's derelict patent office. Now they're extorting any company that wants to do compressed raw recording.
Re:John Carmack on JPEG by TheDudeMan on Friday June 04, 2021 @06:36PM (#27399847)
"you really don't want compression artifacts in X-rays"

You really don't want compression artifacts in any image, which is why you should set the compression ratio wisely when encoding. I don't see how X-rays are any different.

Re:John Carmack on JPEG by kragen on Friday June 04, 2021 @06:41PM (#27399893)
Compression artifacts in X-rays can easily kill people, either by requiring additional unnecessary X-rays (which both delay diagnosis and cause cancer) or by causing erroneous diagnoses; by comparison, the cost of the data storage thus saved is trivial. Compression artifacts in filtered photos of your cute pet turtle for Instagram are much less likely to kill people.
Re:John Carmack on JPEG by simondotau on Saturday June 05, 2021 @12:08AM (#27402088)
And this becomes increasingly true as compression methods get increasingly clever.

https://www.theregister.com/2013/08/06/xerox_copier_flaw_mea...

Re:John Carmack on JPEG by layoutIfNeeded on Saturday June 05, 2021 @05:56AM (#27403647)
Ah yes, the JBIG2 fiasco!

JBIG2 is a format for storing black and white documents in a highly compressed way. It works by detecting each letter in the document, and then replacing it with a pointer to the reference version of that letter, up to a certain threshold. Basically compression via OCR.

Of course, this means that when a distorted letter is too close to the reference version of another letter, it will get replaced with a clean version of that incorrect one. So even though a human could easily recognize that something was off with that letter in the original image, the JBIG2-compressed image has no such clue!

What’s really bad is that JBIG2 compression was built into certain Xerox machines that were used by archivists to digitize important documents for years until someone noticed the discrepancies. JBIG2 was promptly banned for archival purposes, but there might still be a ton of documents with these kind of invisible errors in our archives! :-)

Re:John Carmack on JPEG by nextaccountic on Saturday June 05, 2021 @09:43AM (#27404938)
It would be so cool to add the OCR as metadata. Texts in internet images could be readily selected and available to assistive technologies if images were OCRd at creation time.
Re:John Carmack on JPEG by layoutIfNeeded on Saturday June 05, 2021 @11:47AM (#27406015)
PDF supports this use case by adding an invisible text layer on top of the raster content.

On the other hand, JBIG2 doesn’t actually do OCR. It only does template matching of similar-looking blocks of pixels. The compressor doesn’t try to understand which letter those pixels represent.

Re:John Carmack on JPEG by publicola1990 on Saturday June 05, 2021 @03:58AM (#27403142)
But isnt medical images interpreted by eye only, so artifacts of compression not visible to the eye, those should not be a problem possibly?
Re:John Carmack on JPEG by Synaesthesia on Saturday June 05, 2021 @05:51AM (#27403626)
Artifacts can be visible. Also they can be destructive.
Re:John Carmack on JPEG by skywal_l on Saturday June 05, 2021 @06:04AM (#27403683)
A lot of algorithms are applied to medical images, as pre-processing for eye examination but also for automated analysis.
Re:John Carmack on JPEG by me_again on Friday June 04, 2021 @06:42PM (#27399906)
IIRC there was a study which indicated oncologists' ability to detect tumors in X-ray images was degraded even with lossy compression ratios which didn't introduce obvious artifacts. I couldn't find it with a quick search though.
Re:John Carmack on JPEG by eco on Friday June 04, 2021 @06:39PM (#27399874)
Sure, but you don't normally end up getting an unnecessary biopsy with most other image artifacts.
Re:John Carmack on JPEG by marton78 on Saturday June 05, 2021 @04:53AM (#27403379)
You don't want to do anything lossy in any medical product, otherwise you'd have to prove in the certification process that your lossy compression doesn't introduce any risks.
Re:John Carmack on JPEG by skywal_l on Saturday June 05, 2021 @06:05AM (#27403686)
For storing yes but lossy compression can be useful to improve performance of your UI for example, as long as the user knows that the image displayed has been degraded.
Re:John Carmack on JPEG by clord on Friday June 04, 2021 @06:40PM (#27399879)
some images manage to communicate in spite of high compression. X-rays are an example of an image where the cost of misinterpretation is very high.