Please support this Forum and Neven's Blog

Author Topic: Sentinel 2 Imagery  (Read 8396 times)

Wipneus

  • ASIF Governor
  • Posts: 3147
    • View Profile
    • Arctische Pinguin
Sentinel 2 Imagery
« on: August 02, 2015, 09:51:30 AM »
In the following I am assuming familiarity with the Sentinel 1A products.

Documenting attempts to use the new data.

Sample Sentinel 2 product(s) (only one appeared until now) are becoming available:

- enter S2A* in the search box of the Sentinel data-hub https://scihub.esa.int/dhus/

The download url of the one available sample is:

  https://scihub.esa.int/dhus/odata/v1/Products('a04ba2a6-352d-4b32-a5a8-367ede20ccbf')/$value

It is a 1.4 GB download

Unzipped, the images appear in 4 sub-directories:
 
./GRANULE/<*>/IMG_DATA/

<*> being 4 directories, corresponding to parts of the full image. In this case the original image is split in 4 granules (I would say tiles) each covering a quarter of the area.

The image data are JPEG 2000 images, one for each wavelength band (13 total). Blue (Band 2) has this filename:
S2A_OPER_MSI_L1C_TL_MPC__20150708T160339_A000162_T32TPQ_B02.jp2

S2A the satellite, L1C the data level, datetime and Band can be recognized.

I have not been able to open the image with normal tools:

ImageMagick just say's immediately cannot open:
: no decode delegate for this image format `JP2' @ error/constitute.c/ReadImage/501


[EDIT: this is a possible bug on my Debian Linux computer. See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=773530. I will try the fix]

The Gimp says loading for a minute and then suggest the data is somehow "signed":
Image component 0 of image <filename>.jp2' is signed. This is currently not supported.

Signed as in signed/unsigned integers? Or signed as a form of encrypting/coding?

FIJI (= ImageJ) throws a Java exception. The interesting line in the stack trace says:

Caused by: java.io.IOException: File too long.
   at jj2000.j2k.fileformat.reader.FileFormatReader.readFileFormat(FileFormatReader.java:239)
   at com.sun.media.imageioimpl.plugins.jpeg2000.J2KReadState.initializeRead(J2KReadState.java:451)


Now there is a beta version of the Sentinel 2 toolbox available, although lack of functionality indicates the state is very alpha still.

The toolboxes are now known as SNAP (sentinel application toolbox) from which you can select the different toolboxes. You can download the latest SNAP by going to http://step.esa.int/main/download/, enter name+email address to get the location of the real download pus username/password for retrieving them.

The latest toolbox (beta 5) is not able to open the zip file directly, looking through the forum messages you have to unzip manually and (with SNAP) open the main xml file in the main dir.
That works and you are able to see Bands 2,3,4 and 8. Probably blue,green,red and some infra red channel. Toolbox has the ability to view the RGB bands as a natural color image. It shows a part of north Italy, nice.

(to be continued)








« Last Edit: August 04, 2015, 06:35:22 PM by Wipneus »

Neven

  • Administrator
  • ASIF Governor
  • *****
  • Posts: 3264
    • View Profile
    • Arctic Sea Ice Blog
Re: Sentinel 2 Imagery
« Reply #1 on: August 02, 2015, 11:39:10 AM »
I don't get it, but this is cool. Thanks, Wipneus.
Il faut cultiver notre jardin

Wipneus

  • ASIF Governor
  • Posts: 3147
    • View Profile
    • Arctische Pinguin
Re: Sentinel 2 Imagery
« Reply #2 on: August 02, 2015, 12:36:43 PM »
For those who haven't following it close, Sentinel 2A is the second in ESA's fleet of Sentinel earth observing satellites.
Launched end of June, it is now in some state of commissioning and expected to start with operations sometime in October. Its capabilities can be compared with Landsat 8 but some better specs: 10m color res vs 30m, more spectral bands and more frequent returns.
« Last Edit: August 02, 2015, 12:59:57 PM by Wipneus »

Wipneus

  • ASIF Governor
  • Posts: 3147
    • View Profile
    • Arctische Pinguin
Re: Sentinel 2 Imagery
« Reply #3 on: August 02, 2015, 02:14:03 PM »
GDAL (Geospatial Data Abstraction Library) is able to translate the JPEG2000 files to familiar PNG. The warning message indicates that the data values are signed, negative values are not trandlated:

:
$ gdal_translate -of PNG  <filename.jp2> <filename.png>
Input file size is 10980, 10980
Warning 6: PNG driver doesn't support data type Int16. Only eight bit (Byte) and sixteen bit (UInt16) bands supported. Defaulting to Byte

0...10...20...30...40...50...60...70...80...90...100 - done.

Converting to tiff is also possible of course and allows me to verify that none of the values in this files was actually  negative. They could just be causing unnecessary pain by using a signed data type.

Finding an url or email address to report such problems is not easy on the web site.

Wipneus

  • ASIF Governor
  • Posts: 3147
    • View Profile
    • Arctische Pinguin
Re: Sentinel 2 Imagery
« Reply #4 on: August 02, 2015, 05:18:17 PM »
Reading/converting with GDAL, combining to RGB with ImageMagick and selecting a sub scene with the Gimp gives the attached image.

The river Po on the left , the village Suzzara on the right. The alignment of the three channels is visibly not perfect yet, that is what the engineers are working on right now.

A-Team

  • ASIF Upper Class
  • Posts: 1656
    • View Profile
Re: Sentinel 2 Imagery
« Reply #5 on: August 04, 2015, 06:44:29 AM »
Using Fiji (imageJ2) I was able to open a sample .jp2 file provided at http://www.fnordware.com/j2k/jp2samples.html -- it opens as a stack of 3 bands which using Color -> Stack to RGB did recover the original image, suggesting it would open as many bands as are present. (It's important to quit Fiji regularly and restart, to pick up all the updates.)

Even this small simple file gave an error message in Gimp and opened recognizably but very bizarrely in Safari, as all-black in Chrome, and not at all in Firefox. Preview in Mac Yosemite can save to JPEG2000 but not open files in that format! The forum will not load .jp2 files. The computer world is awash in file formats that no one is interested in supporting and this is one of them.

The sample file above is probably not signed but note it already shows this file format standard is rarely supported, which you can also see in the obsolete list of supporting software at wikipedia.

The link you provided does not work in Firefox because Sentinel links use parenthesis which are unacceptable in urls (replaced by spaces) but do trigger the download in Safari
https://scihub.esa.int/dhus/odata/v1/Products('a04ba2a6-352d-4b32-a5a8-367ede20ccbf')/$value

I wonder what ever possessed them to use this file format which never gained any traction and for most practical purposes had been abandoned before they ever adopted it. Using signed when they didn't use signs suggests again, like granule instead of tile (and elsewhere the peculiar word choice 'manifest' and SAFE which have nothing to do with manifests or safety), they don't know what they are doing.

Or live in their own little world of a specialized proprietary software where they are saving these files out of, maybe thinking they were making an advancement over regular jpeg discrete cosine with wavelets. People can do wavelets (a variant on fourier transform) on their own time, that is supported everywhere (Gimp, ImageJ, ImageMagick).

Granule may mean something larger than a tile though it should really mean something smaller (grain). Or it may be synonymous. In some places, they speak of using GML-JPEG2000 format rather than JPEG2000 (aka .jp2). Amusingly, comments are welcome even though NO COMMENT BOX is provided!

Geography Markup Language (GML) has many pages of 'standards' of its own http://www.opengeospatial.org/standards/gml The basic (?) idea is:

GML serves as a modeling language for geographic systems as well as an open interchange format for geographic transactions on the Internet. As with most XML based grammars, there are two parts to the grammar – the schema that describes the document and the instance document that contains the actual data. A GML document is described using a GML Schema.

Yes but 'GML Schema' just sends you off on another unending chase for an explanation or example. There is a disconnect between people who sit on formal standards committees and their target audience which, unbeknownst to therm, is larger than fellow programmers. They are seeking the most general possible abstraction and so enable a vast hypothetical feature set, the problem being no one implements a tenth of it in the real world, so all the complexity was for naught.

Landsat has 11 bands, S2A only 13. Why not simply do .tiff like Landsat did? Or why not just use the vastly more efficient lossless .png? I think the whole problem is trying to do too much in overly general schemas. The end users just want a simple graphics file they can open and process in their favorite among the innumerable programs and platforms in use. It just gets more balkanized every year.

Google search on GML-JPEG2000, JPEG2000 and jp2 shows that the #1 interest is in file converters that get you out of GML-JPEG2000, JPEG2000 and jp2 into something recognizable. However I found the free file converters only supported part of the format's core, not the whole schema.

Nothing about 'signed' in their explanation, in fact it seems ruled out by 'radiance value' and 'physical gain factor':

Each pixel value is encoded in 12 bits and is directly proportional to radiance values using physical gain factors. The image data is provided by a set of raster files, either a file per spectral band and per granule, or a file per spectral band and detector [explained somewhere else?] corresponding to the aggregation of granules along track. Each image file is compressed, in LOSSLESS mode, using the JPEG2000 algorithm.

Their server situation is a joke. It takes several minutes to search S2A* even though there is just one such file; then they send the 1.5 GB zipped file over a very slow connection that tends to disconnect repeatedly as well as time out during the download, which I see all the time in Sentinel 1-A too (but not elsewhere such as Landsat). It does no good to have a fast connection facing a slow server -- ironic since their annual budget is a million times mine.

Given the difficulties, what was the purpose of only offering a gigantic sample file? That is only going to compound the issues of users trying to find software that even opens this rarely implemented rarely used 15-year old 'standard'.

I've attached a full size uncompressed version of their incoherent explanation. Any questions? (The 305 character url had to be shortened, http://tinyurl.com/nf8dsnj)

I eventually located the help desk last week after much surfing of their site and submitted a polite reasonable question to which they eventually responded with a very helpful explanation about re-projecting Sentinel-1 into Landsat UTM.
http://forum.arctic-sea-ice.net/index.php/topic,1355.msg60306.html#msg60306

The whole bewildering, disorganized redundant Sentinel site is a prime example of incompetent technical writing which they seem to have contracted out and then been stuck with (not really caring). It does go through the motions of explaining Sentinel use and evidently that was enough to get a pass on contract terms.

The Sentinel satellites are advanced scientific instruments with sophisticated capabilities. Oh, by the way, they take ground pictures too. Through dark and clouds with high repeat coverage. Sadly, their boorish end users  just want these pictures. Indeed google search suggests that the primary known users globally of Sentinel satellites have been DMI and 4-5 people on these forums.

This happens with a great many satellites. The PIs write a paper or two using all the design capability, maybe a daily online product that attracts little interest and soon becomes obsolete. Some minor aspect of the capability still attracts some users. The terabytes of data continue to pile up but user interest has died. After a while, the ground station's budget moves on and data is no longer collected or served, leaving the poor satellite transmitting away but nobody receiving.

I've noted before with Sentinel 1A that even the massive IW high resolution files barely provide a better picture than a lowish resolution preview DMI. This suggests that they could carve out the pictures from Sentinel and serve them separately at moderate resolution as .pngs, thus eliminating 99% of the demand on their servers.

In summary, the Sentinel office does exactly as they please, there is no accountability or interaction with the external user community.  Ok, but why offer a public server and encourage people to register? All this for the crappy ground resolution (Italy above) that will amount to 99% of end use.
« Last Edit: August 11, 2015, 03:33:40 PM by A-Team »

Tealight

  • ASIF Citizen
  • Posts: 235
    • View Profile
    • CryosphereComputing
Re: Sentinel 2 Imagery
« Reply #6 on: March 11, 2016, 02:10:51 AM »
Just to keep this thread updated.

Sentinel 2 images will soon (mid 2016) be available over Earth Explorer. So everyone who wants to download Landsat and Sentinel2 on one site can do this there.

future download:
http://earthexplorer.usgs.gov/

additional info:
http://eros.usgs.gov/sentinel-2

A-Team

  • ASIF Upper Class
  • Posts: 1656
    • View Profile
Re: Sentinel 2 Imagery
« Reply #7 on: March 13, 2016, 07:41:45 PM »
Sentinel 2 images will soon (mid 2016) be available over Earth Explorer.

Good spotting! A bit of a repost of a JI forum post. I hope people here will take up the opportunity to send suggestions to USGS via custserv@usgs.gov.

EarthExplorer has a checkbox for Sentinel 2A as of today in its Data Sets column that allows a bypass of the klutzy Sentinel portal. There is nothing there yet for Greenland but I downloaded of a bit of SE Iceland.

The files are enormous at 5.8 GB, some 7x the size of a Landset folder. Sentinel's file format is an unresolved nightmare involving their very peculiar choice of .jp2 (jpeg2000) which cannot be displayed on this forum or for that matter in any web browser.

You cannot even save out of jp2 because it can't opened in ImageJ or Imagemagick as the files are too large and complex for Java. Don't look for that to be remedied any time soon by Oracle. There's nothing the programmers can do on their own.

Gimp can open these but only in 8-bit depth whereas Sentinel 2A is, like Landsat, 12-bit bumped to 16-bit by bicubic interpolation. As opened as layers in Gimp, the .jp2 provide a crazy range of 6 different resolutions. This makes no sense as users can easily reduce resolution to anything they want -- which would hardly ever be one provided. 

USGS serves a decent RGB (bands 2-4) preview of Sentinel 2As that will again open in Gimp but not in ImageJ because it's in GeoTIFF format rather than TIFF.

That's a pity because ImageJ (but not Gimp) allows contrast enhancement in 16-bit mode prior to making the 3 x 8-bit RGB. This is a huge issue over ice at high latitude (Antarctica, Canada, Alaska, Greenland). True, the RGB can be split into its channels, enhanced, and reassembled back to RGB but only as pixellated 8-bit.

USGS additionally serves a very similar jp2 (jpeg2000) as a Tile (same package as ESA). The USGS files too cannot be opened in ImageJ or ImageMagick until Java itself is updated to unpack these hugely complex and  enormous files.

As part of testing of the ESA-USGS operational distribution flow, a limited number of Sentinel-2A products are now available for search and download via USGS EarthExplorer.

The anticipated product options from USGS will include a Full-Resolution Browse (FRB) image product generated by USGS, along with a 100 x 100 km tile-based Level-1C top-of-atmosphere (TOA) reflectance product that will be very similar (but not identical) to the currently distributed ESA Level 1C product. An initial release of these two product types is anticipated in early-mid 2016.

We would welcome any available input or feedback from the user community.Please provide comments or suggestions regarding the future Sentinel-2A product options to: custserv@usgs.gov.

I hope a lot of users here will write USGS about how to improve this service. Otherwise we are going to be effectively shut out of Sentinel 2A (because ESA does not welcome end-user imput).

Good documentation and sample files at http://eros.usgs.gov/sentinel-2 if you open all the done-wrong triangles.

Looks like GeoJasper can do the conversion out of jp2. It is command line. I have not yet had a chance to try it.

http://www.dimin.net/software/geojasper/

tif3f2jp2  - converts 3 TIFF 1 channel images into RGB jp2 (5 times compr),
             ex: tif2jp2 geo1.tif geo2.tif geo3.tif geo.jp2

tif2geotif - converts TIFF image plus world file into GeoTIFF
             (must have: img.tif img.tfw)
             ex: tif2geotif img.tif img
             
listgeojp2 - prints Geo information contained in the file without
             actually decoding it,
             ex: listgeojp2 geo.jp2
             
jp2tif4tiles - converts JPEG2000 into tiled TIFF with tile size 256x256
               ex: jp2tif geo.jp2 geo.tif
               
jp2tif4tiles64 - converts JPEG2000 into tiled TIFF with tile size 64x64
                 ex: jp2tif geo.jp2 geo.tif
« Last Edit: March 14, 2016, 12:40:53 AM by A-Team »

sidd

  • ASIF Middle Class
  • Posts: 990
    • View Profile
Re: Sentinel 2 Imagery
« Reply #8 on: March 14, 2016, 03:36:30 AM »
Re: ImageMagick, filesize, java

IM is written in C i am fairly sure, having compiled it  in the last year or so, and has no file size limit,  I have had no problem handling 10+ gig images on the appropriate hardware. I dont understand the java dependency. Also i have never had a problem yet with the jpeg2000 format in ImageMagick.
perhaps a pointer to the jpeg2000 file that causes trouble might help me understand ?

for fun i downloaded some sentinel2 from earthexplorer, had no trouble with any jp2 inside the zip downloads

sidd


Wipneus

  • ASIF Governor
  • Posts: 3147
    • View Profile
    • Arctische Pinguin
Re: Sentinel 2 Imagery
« Reply #9 on: March 14, 2016, 12:03:36 PM »
My problems with ImageMagick and jpeg2000 files are over after installing the version from the  experimental branch of my Linux OS (Debian stable).

Seems ImageMagick are now using the OpenJpeg libraries, previous libJasper. The maintainer of the ImageMagick had not pressed the necessary switches.

A-Team

  • ASIF Upper Class
  • Posts: 1656
    • View Profile
Re: Sentinel 2 Imagery
« Reply #10 on: March 14, 2016, 02:05:09 PM »
Let's see, we have 892 members of whom 3 work in terminal mode. The rest have no access to Sentinel 2A.

Are you sure that you have bands 2-4 in 16-bit, 10 m resolution, tif format, no compression losses?

Otherwise we are going to lose out in terms of feature tracking because glaciers and ice sheets present very different optimization issues than pictures of the Amazon, Milan etc.

Even if converted to some mainstream format, there seems to be no way to post/attach/share them on this forum at full bit depth. jpeg2000 cannot be displayed in any web browser. Personal ftp sites? ... who is going to reprocess and host terabytes of Sentinel 2A in a common file format?

These bands need to be seriously processed at 16 bits before combining into RGB because we are not so interested in true reflectance values / true color here (except maybe for meltwater, albedo, eye candy) but rather with feature identification and displacements which are shades of white contrast issues. There is very little color on an ice sheet.

My understanding of Sentinel 2A is pan-sharpening is not applicable: all the visible sensor channels are at 10 m, there is no panchromatic channel at higher resolution. However 10 m is a significant improvement over Landsat relative to intrinsic glacier scales (eg crevasse widths and meltwater filling); it will probably still be good at 5 m.

It might be worth looking at principal component analysis, ie taking the first component PC1 of bands 234. If there is any gain to that, then there needs to be central bulk reprocessing

The first thing to do is look at the 3 band histograms of an all-ice (no dark rock or ocean) Greenland or Antarctic scene.

I'm going to guess the middle channel (band 3 green 0.560 µm) will have a 'better histogram' than the red or blue, ie better utilization of the permissible range of values, rather than sharply peaked. If so, then making an RGB may actually degrade glacial images rather than add value.

If you look at the 16-bit histograms of Sentinel 1As and early season or hazy Landsat-8s, they are truly shocking: there's hardly any utilization of the color space. Consequently they are incapable of being reprocessed into sharp images. These are really only 6-bit or less.

There's a harmless (reversible) first step on these that may be applicable to Sentinel 2A as well: squeeze out unused space with a linear contrast tool. That may leave it losslessly in 8-bit.

Below are the histograms for a recent Landsat, 2016 062 09 11 LC80090112016062LGN00. Note all three channels use less than half of the brightness range. Band 5 is actually slightly more favorable than band 4 whereas band 3 has collapsed at the low end. The second animation shows the histogram after a simple auto-correction of brightness.

Various local and global statistics can pick out the most favorable channel for respective end purposes (3rd image). You can't make a silk purse out of a sow's ear.

My problems with ImageMagick and jpeg2000 files are over after installing the version from the  experimental branch of my Linux OS (Debian stable). Seems ImageMagick are now using the OpenJpeg libraries, previous libJasper. The maintainer of the ImageMagick had not pressed the necessary switches.
Since I got the identically worded error message in ImageJ, perhaps the maintainer of that (or BioFormats) could do the same, fixing ImageJ with these same libraries. I must say though that opening the Sentinel 2A jp2 works in Gimp but who wants 6 layers 5 of which are junk? (jpeg2000 was designed to load successively better resolution versions but the need for that evaporated with faster internet connections.)
« Last Edit: March 14, 2016, 02:41:57 PM by A-Team »

Wipneus

  • ASIF Governor
  • Posts: 3147
    • View Profile
    • Arctische Pinguin
Re: Sentinel 2 Imagery
« Reply #11 on: March 14, 2016, 06:35:54 PM »
Are you sure that you have bands 2-4 in 16-bit, 10 m resolution, tif format, no compression losses?

I have not processed any file since last summers pre-release sample. The missions reports say that the "bit quantisation" has been "increased to 10,000 values" since then. That would be a "bit" over 13 bits, so 14 bits numbers.

Agreed that 8 bit is inadequate for many ice and snow scenes.

 
I must say though that opening the Sentinel 2A jp2 works in Gimp but who wants 6 layers 5 of which are junk?

That sounds like a Gimp "feature". There are not really 6 separate layers in the image, but it is possible to extract the same image in 6 different compression levels from the same file (which is done, loosely explained, by including more or less higher Fourier frequencies) .


Tealight

  • ASIF Citizen
  • Posts: 235
    • View Profile
    • CryosphereComputing
Re: Sentinel 2 Imagery
« Reply #12 on: March 14, 2016, 07:41:59 PM »
I'm definitely not an image processing expert, but until now I got reasonable quality from exporting the S2A RGB images from SNAP as a png file and then correcting the reflectance in GIMP with the curve tool. Without correcting the reflectance the only bright part are clouds and the rest is far too dark. I'm pretty sure Greenland would have similar problems from fresh snow, bare ice and clouds.

For the bitsize I can confirm that the images have over 10,000 brightness values. The highest pixel I found manually had 14198, although most bright areas have around 10,000.

Attached is the pixel value (brightness) statistic from a water/desert area close to the Suez canal.

What is the maximum attachment size for this forum? When I tried to attach a 31MB picture I got an error.
« Last Edit: March 14, 2016, 08:09:38 PM by Tealight »

A-Team

  • ASIF Upper Class
  • Posts: 1656
    • View Profile
Re: Sentinel 2 Imagery
« Reply #13 on: March 15, 2016, 02:09:41 PM »
That sounds like a Gimp feature.  not  6 different compression levels from the same file (which is done, loosely explained, by including   higher Fourier

Indeed Gimp is quite strong on wavelet transformations which are more effective on non-periodic satellite imagery than fourier expansion and band pass filtration. Wavelets are the key idea behind jpeg2000 (jp2).

In those years, homes with cutting edge technology accessed the internet with fixed telephone lines called dial-up connections (ask to see at UA computer museum http://www.amsterdam.info/museums/computer-museum/). It took forever for overall pictures to load because (in existing formats) because data came in block by block starting top left.

With jpeg2000, an entire image streamed in quickly with a small amount of data thanks to a low order wavelet. That image was imperceptively improved as the minutes went by as it got replaced with higher orders. A breakthrough? Maybe, but jpeg2000 was never adopted because internet connections got faster.

The 6 levels are actually specified in the Sentinel 2A file or at least in the USGS 'GeoTiff' preview image made from it. However nobody is interested in them today because Gimp can quickly decompose any image format into any depth of wavelets. If you delete some of these and reconstitute the image, it filters out those frequencies. It seems like that should clean up Sentinel 1A images but I've not seen a benefit.

reasonable quality from exporting the S2A RGB images from SNAP as a png file and then correcting the reflectance in GIMP with the curve tool.

The physical sensors on the satellite are somewhat noisy analog devices. Because of instrument limitations, incoming data is only worth storing (digitally) with 12-bit precision, meaning as one of 4096 possibilities in binary. You can think of this as having "more decimal points" than the 8-bit precision of older satellites (256 possibilities).

This is actually a huge technical advance because 12-bit gives more 'room' to reprocess the image without degrading it by round-off errors during unavoidable downstream steps (re-gridding, rotating, brightness rescaling, gamma) from the perspective of the end-user viewing it on a color monitor (3 channels of 8-bit gray). The histogram will still appear continuously smooth.

Image software works at the 8-, 16- 32- and 64-bit levels because of the byte nature of physical RAM. You can always make a 12-bit into 16-bit by simply adding zeroes. However here reprocessing steps interpolate, taking image data naturally into 16-bit. Of the 4 common interpolation methods, both Sentinel and Landsat chose bicubic, a good decision that likely adds slight precision on ice sheets.

If you do basic reprocessing steps starting with 8-bit image, the histogram will degrade into a collection of vertical spikes. It is no longer smooth as it has been reduced to a subset of the 256 values. In effect it has lower bit depth. The monitor image will no longer have smooth shades of gray but abrupt steps in contrast. It's not just aesthetics either as it degrades quantitative analysis too.

For this reason, we want to get our hands on the 16-bit layers for bands 234. The png format only comes in 8-bit as far as the spec goes. You can verify this by opening the SNAP toolbox offerings in ImageJ which shows the bit depth under Image --> Type. ImageJ also supports 32-bit. Gimp won't provide this since it is 8-bit only until they switch over to the new GEGL libraries.

The advantage of png over ordinary jpg is it still carries the alpha (masking) channel. In gimp, the checkerboard used for transparency, will show up as forum background white (a 245 grayscale). That gives a nice effect of integrating your image seamlessly into the page. You can share a mask in this way.

There's still no S2A Greenland imagery at EarthExplorer. Below is the high resolution GeoTiff somewhere in the Davis Strait with a forum background cutout.

Png 8-bit is a terrible thing for ice sheets. We need to have 16-bit tifs to fix the contrast. I'm willing to look at ImageMagick but at this point, only Wipneus and sidd can make these. sidd never posts satellite images; Wipneus prefers minimal manipulations and has no way of sharing 16-bit tifs over the forum.

Our only hope is USGS at EarthExplorer because Sentinel is too inexperienced at open source and too proud to consider end user input. Of course most of the users are just interested in cities, farms, forests, oceans, or mineral extraction.

Without correcting the reflectance the only bright part are clouds

In this situation, make a binary mask. Then only the good stuff is processed and on the histogram. Then you can see interactively what is going on with contrast adjustment choices.

Clouds are too bright, rocks are too dark, the fjord ice is too seasonally variable. These are easily selected in Gimp by thresholding or magic wand. If the borders have too much micro detail, 'grow' the border by 1 pixel to simplify it.

Cirrus clouds can be removed by local contrast enhancement (CLAHE) in ImageJ. This is really the best single tool out there for fixing ice sheet contrast. The other tools act on global statistics but this acts locally to fix each patch in proportion to its relative needs.

maximum attachment size for this forum?  a 31MB picture got an error.

No one seems to know the rules. There is no FAQ. Forum software does a lot of funky things to large images, refusing some, thumbnailing others, dumbing down even a 700 pixel one depending on sizes of the other 3 (four attachments is max). It will display a 700 x 700 animation however. I try to stick to 700 x 700 unless it means unacceptable degradation.

A lot of visitors will not click through to full size unless you tell them to. This results in miscommunication when they only see your best work at crummy resolution.

I'm traveling this week and will be offline.
« Last Edit: March 15, 2016, 03:08:20 PM by A-Team »

sidd

  • ASIF Middle Class
  • Posts: 990
    • View Profile
Re: Sentinel 2 Imagery
« Reply #14 on: March 15, 2016, 11:03:12 PM »
" ... sidd never posts satellite images ..."

ooo, sorry. here is a jp2,tiff pair made using the convert command from ImageMagick
both have 15 bit rez, the tiff is much larger ... both display fine using IM display command.


http://membrane.com/sidd/s2a/


Tealight

  • ASIF Citizen
  • Posts: 235
    • View Profile
    • CryosphereComputing
Re: Sentinel 2 Imagery
« Reply #15 on: March 16, 2016, 12:40:23 AM »
I'm traveling this week and will be offline.

That's ok, you always post so much information, that it takes me over a day to go through all.

I tested other SNAP image exports, but never got 16bit images. Either its 8bit for jpg/bmp or a 24bit RGB export for tiff/png even if the actual band is in grey-scale.

I'm doing most of the image processing inside SNAP, so I'm not affected by 8bit losses. Is the quality loss really that noticeable? Most forum users won't have a professional monitor anyway and probably haven't calibrated it perfectly.

Furthermore the S2A images we get are already processed and lost detail. All images I looked at have show very clear lines, which shouldn't be as straight and have uniform colour. i.e. All cities look like ghost towns without any cars on the streets or aircraft on airports. I'm not sure how it influences glaciers in Greenland, but I doubt they change their processing algorithm for these areas.

A-Team

  • ASIF Upper Class
  • Posts: 1656
    • View Profile
Re: Sentinel 2 Imagery
« Reply #16 on: March 16, 2016, 01:35:46 PM »
I tested other SNAP image exports, but never got 16bit images. Either its 8bit for jpg/bmp or a 24bit RGB export for tiff/png even if the actual band is in grey-scale.
Briefly, I think you are on the right track with SNAP. It is poised to take over. As a work in progress, they might be responsive if you ask for 16-bit tif export of individual bands (ie be like Landsat). Not a big deal to add that feature, just an open source library. The request is well-motivated and tifs would huge difference in scientific end use.

Look at the histogram on the image sidd provided (below). Nice sharp image but horrible histogram. (Note posting as 15-bit is silly -- physical memory architecture comes in fixed 8n block sizes.) Look at Espen's many dark dark animations -- we need to make it easier for people to fix their postings. Large files + many estoteric steps + Linux  = little utilization of Sentinel 2A.

We are not doing farm crops or jungles here. We are Nares Straits, three marine terminating glaciers in Greenland, and three ice shelves in Antarctica. Canaries in the coal mine for sea level rise.

We are the early early warning system -- the most common comment we hear from working glaciologists is 'thanks for looking at all those satellite images, we simply don't have time to do that.'

S2A image are already heavily processed... doubt they change their processing algorithm for glaciers in Greenland.

They won't change a thing (requires too much intervention) plus some scientists want literal reflectance values. We don't. However we are ok starting with them if no information was discarded (still 16-bit). 

Here is what Sentinel 2A is really all about for the cryosphere. Not just supplemental coverage of Sentinel 1A and Landsat-8 giving denser time series. Not just sharper images of crevasses and other glacial features. It's all about detecting acceleration.

Take the case of Jakobshavn/Petermann/Zachariae, the three canaries in the Greenland coal mine. It's easy enough to measure ice stream velocities but another thing altogether to accurately measure secular trends in those velocities (eg is Jakobshavn still accelerating, has the velocity plateaued, or is it maybe slowing back down?).

That involves subtracting velocities already having limited precision. The numbers are derived from feature tracking 15 m pixels. Better numbers come from tracking 10 m pixels. When features are sharper, more can be tracked over longer time periods. You can test that in Gimp by degrading a Landsat pair with the noise tool.

And so it all comes down to optimizing contrast. With 8-bit, they're putting a two dollar saddle on a billion dollar mule.

It matters whether Greenland melts out in 50 years vs 5000. That's why we want 16-bit Sentinel 2A bands 234.
« Last Edit: March 16, 2016, 01:43:14 PM by A-Team »

A-Team

  • ASIF Upper Class
  • Posts: 1656
    • View Profile
Re: Sentinel 2 Imagery
« Reply #17 on: March 16, 2016, 03:42:25 PM »
The next step comes this week when we can look at the first Sentinel 2A imagery of Jakobshavn. First, something to compare to Landsat in the calving front and crevasse region; second to show that "it matters" for resolving detail and measuring velocity to start with the 16-bit bands rather than SNAP's 8-bit per channel pngs, third to see if RGB adds any value.

It will be infinitely more effective in contacting the powers that be if we can include a pdf of 8-bit vs 8-bit contrast-adjusted at 16-bit. These can be subtracted to a third image that shows where and how much they differ and why that difference is significant.

More ambitiously, on a clear cold day some of the near IR bands might have information on surface temperature. (This data is 20 m pixels rather than 10 but I believe still 16-bit.) The idea here is the shearing forces are so colossal and heat diffusion so slow that the side junctions with large velocity contrasts have to be warmer, notably around the elbow.

It's instructive to see how Sentinel 2A and Landsat-8 get used in the analysis of Norwegian glaciers: division of channel values plus AND requirements. So far we have done very little on these forums with the common arithmetic operations for normalized indexes such as (channel x - channel y) /channel x + channel y).

http://congrexprojects.com/docs/12c04_docs2/poster1_39_winsvold.pdf
« Last Edit: March 16, 2016, 03:53:08 PM by A-Team »

sidd

  • ASIF Middle Class
  • Posts: 990
    • View Profile
Re: Sentinel 2 Imagery
« Reply #18 on: March 16, 2016, 10:22:39 PM »
ImageMagicK has a bunch of ways to manipulate, and Weinhaus has more scripts on his page

http://www.imagemagick.org/Usage/color_mods/


http://www.fmwconcepts.com/imagemagick/redist/

the redist script massages the histogram into a uniform or a gaussian, but it can be modified to do just about anything ...

sidd

  • ASIF Middle Class
  • Posts: 990
    • View Profile
Re: Sentinel 2 Imagery
« Reply #19 on: March 17, 2016, 04:43:49 AM »
the histogram from the original jp2 is the same as that for the tiff . I enclose it below.

Using redist or one of the clever IM flags on convert allows that histogram to be distorted as one pleases. I did a couple trix with those, using the -normalize and -equalize flags on convert, and then with redist with the -s normal and gaussian options, and it worked like it said on the box.


A-Team

  • ASIF Upper Class
  • Posts: 1656
    • View Profile
Re: Sentinel 2 Imagery
« Reply #20 on: March 22, 2016, 10:44:02 AM »
options, and it worked like it said
None of these will produce good outcomes.

The reasons are fourfold. First the original image requires interactive masking that is impractical in ImageMagick (the ocean contributes most but not all of dark spike => operator knowledge of scene plus interactive intervention required).

Second, if you look closely at what's left of histogram occupation after masking, you can see that all that was accomplished in this instance with the 12-bit precision in the satellite sensor was to get (at most) 8-bit data: less than half the dynamic range was actually utilized to any extent.

Image enhancement can draw out information if it was initially present but cannot go beyond what was actually sensed (make stuff up out of thin air). Because the data never really had 16-bit precision to begin with, it's not possible to manipulate the image without pixelating the histogram (the image as presented to an 8-bit monitor facing the internet). Round-off errors will kill the image quality.

Third, despite the merits of command line shells, for every user there, Photoshop has ten thousand -- it doesn't work to fly blind. It's too slow in a production environment to try things that 'should work' but don't. Every image has to be processed separately because of its one-off issues (for ice sheets: sun angle, clouds, snowdrift, melt or ablation state).

It's more efficient to explore huge parameter spaces of potential adjustments with interactive sliders. And of the many thousands of published contrast algorithms, the useful ones are quickly scooped up by the mainstream GUIs.

Fourth, ice sheets have not been a mainstream topic in the image enhancement literature. When a specialized obscure need comes up, say measuring Greenland melt lake depths from Landsat-8, you won't find the algorithm for doing that sitting around pre-scripted.

Biomedical is our 'nearest neighbor', not the other highly developed areas in image processing (vegetation, astronomy, military reconnaissance). Medicine has seen a huge effort on tools that optimally improve low contrast images and display spatial time series.

For that reason ImageJ with Gimp is probably the best entry point for forum users who want fast and free image manipulation, or at least a better level of it. However they are not without learning curves.

ImageMagick may have a lot of great commands but it is not at all specialized to cryosphere processing. We are yet to see anything special to it in the last 71,351 forum posts.

There was supposed to be Sentinel 2A Jakobshavn imagery for both 11-22 Mar 16 and 19-30 Mar 16 so we can see what works  (though it has been cloudy). Talk is cheap. I go by uploaded attachments, period.

https://sentinel.esa.int/web/sentinel/missions/sentinel-2/acquisition-plans
« Last Edit: March 22, 2016, 10:59:46 AM by A-Team »

Tealight

  • ASIF Citizen
  • Posts: 235
    • View Profile
    • CryosphereComputing
Re: Sentinel 2 Imagery
« Reply #21 on: August 24, 2016, 09:46:07 PM »
Sentinels DataHub will start using single-tile packages in Autumn 2016 instead of a whole tile grid.

At the same time new product naming will be introduced to overcome the 256 characters limitation on pathnames imposed by the Windows platforms.


https://scihub.copernicus.eu/news/News00092