Subscribe to this thread
Home - General / All posts - Linking ECW with Alpha
joebocop
431 post(s)
#19-Nov-20 23:19

Does Release 9 support ECW with Alpha?

I have an ecw which loads "correctly" in GlobalMapper, QGIS, ArcGIS and MapInfo, but I can't get it to "work" in Manifold.

Here is how the channels are configured, and the resulting image. Also shown is the gdalinfo output.

Here is the config in QGIS that yields the desired display

and the transparency

Thank you!

Attachments:
manifold_ecw.png
qgis_bands.png
qgis_xparency.png

oeaulong

271 post(s)
#20-Nov-20 03:02

I just pulled down a random ECW 4-band and have not had issues (linked from a global mapper forum page)

Have you tried displaying at 3-band RGB, ignoring the Alpha channel?

Try auto-adjusting the contrast of that one Alpha/Channel 3.

Dimitri


6,276 post(s)
#20-Nov-20 08:08

The question is more about what different versions of ECW support and how they do it. From the ECW topic you can see that Manifold reads ECW files using the latest version of the Hexagon SDK for reading ECW. ECW is a proprietary format of Hexagon, so whatever Hexagon says is a correct ECW file is authoritative, and using Hexagon's own code is authoritative as well.

ECW files written prior to the 4.1 SDK don't have an opacity channel. ECW files with 4.1 or after can have an opacity channel, but it can have only one of two values: 0 for no opacity (that is, full transparency) or 255 for full opacity (that is, no transparency). This is backwards from the default assumption for most GIS packages, including Manifold, of how an alpha channel should be used.

From the Example: Set Image Transparency using Alpha topic:

Opacity or Transparency? - Alpha channels may be interpreted as setting either opacity, or transparency. When an alpha channel sets opacity, a high value in the channel means greater opacity, with a value of 255 meaning completely opaque and a value of 0 meaning totally transparent. When an alpha channel sets transparency, a high value means more transparency. Some formats, such as TIF images, specify alpha as opacity, so that is how Manifold imports alpha channel data for TIF, interpreting 255 as full opacity. Other packages and formats use transparency for alpha, and sometimes alpha data in TIF is stored using transparency. The default setting for internal use by Manifold is to interpret alpha as transparency, as is shown above in this topic.

If alpha data is ever imported and is flipped from how it should be, using transparency instead of opacity or vice versa, and the reverse is required, that is easy to arrange using Manifold's automatic inversion capability, as discussed in the section titled Example: Automatic Inversion in the Style: Images topic.

OK. In the Style setting you show, the alpha channel is set to 0, but the image doesn't show (fully transparent). I'm guessing that means the image was imported with the fourth channel as opacity and not transparency, but the value in how it was written was intended for transparency. So the first step is setting the value of Channel 3 to 255. How does that work? Does the image appear (don't forget to press the Update Style button after making that change...).

Note that automatic inversion can't save you here, because that can guess based on a range of values where one extreme is greater than the other, and you don't have that as a guide when the channel is either all 0 or all 255.

Note also from the ECW topic that when Manifold writes, it writes using a pre 4.1 SDK, so any ECW written by Manifold doesn't use the opacity mask channel. The back story to this is that when Manifold and ER Mapper worked together on the SDK, Manifold got a perpetual license to use the full SDK for free. Since then, ER Mapper ended up being acquired and the technology passed through multiple hands with many revisions. Manifold today can use the latest SDK for free for reading but that has big limitations on writing. To get around those limits, Manifold uses the older SDK to write, allowing writes of unlimited size ECWs.

As to why other packages import, it appears you also have to make a manual adjustment in Q. I'd be interested in getting a sample of the actual file. My guess is that whatever package wrote it just assumed that ECW used "transparency" and not "opacity" and coded the bit at 0 when it should have been coded 255. When Manifold reads the file with correct interpretation, that ends up being backwards. Or, it could be vice versa. Can't say without seeing the file.

I've contributed this as a suggestion, to add a discussion on transparency to the ECW topic.

adamw


9,445 post(s)
#30-Nov-20 13:34

The first screen shows that all channels have ColorInterp = Undefined. That's probably the reason the image is not getting recognized as having the alpha channel (channel 3 is set to: channel 3, min 0, max 0 - a little weird, we'll look into why that happens, normally you would see channel 3 set to simply: value 0). You can likely get the correct picture by setting channel 3 to: channel 3, min 255, max 0.

In general, could you please contact tech support and send example file that exhibits this behavior?

Manifold User Community Use Agreement Copyright (C) 2007-2019 Manifold Software Limited. All rights reserved.