Plot true color Sentinel-2A image
10 views (last 30 days)
Show older comments
Through a combination of non-matlab/non-native tools (GDAL) as well as native tools (geoimread) I can ingest Sentinel-2A data either a indiviual bands or as an RGB image having employed gdal merge. I'm stuck at a point where using
imshow(I, [])
Produces a black image, with apparently no signal. The range of intensity values in the image are 271 - 4349. I know that there is a good signal in the image because when I do
bit_depth = 2^15;
I = swapbytes(I);
[I_indexed, color_map] = rgb2ind(I, bit_depth);
I_double = im2double(I_indexed, 'indexed');
ax1 = figure;
colormap(ax1, color_map);
image(I_double)
and index the image, collecting a colormap, I get a likeness of the region I'm exploring (albeit very strangely colored)
I'm currently considering whether I should try:
- Find a low-level description of Sentinel-2A data, implement the scaling/correction
- Use a toolbox, possibly this one.
- Possibly adjust ouput settings in one of the earlier steps involving GDAL
Comments or suggestions are greatly appreciated.
2 Comments
Matthew Cooper
on 27 Jul 2019
You might try pcolor or even something simple like contourf just to make sure the values are there (you would need to define x and y (lon and lat) vectors as well). You might also try geotiffread (if the data are saved as a .tif file) to ingest the data which would provide a MapCellsReference object which woudl allow you to use the in-built Matlab geospatial plotting functions, or if the data are not saved as geotiff go ahead and use geoimread and create a georeference object yourself and then try geoshow(I,R,'DisplayType','Surface') or one of the other display type options. Finally, if you post your Sentinel data file, I will have a look and figure it out for you.
Iskander Benhadj
on 23 Mar 2020
Edited: Iskander Benhadj
on 23 Mar 2020
dear,
to show the image using the imshow, you need to scale the image between 0 and 1
bit_depth = 2^15;
I = swapbytes(I);
[I_indexed, color_map] = rgb2ind(I, bit_depth);
I_double = im2double(I_indexed, 'indexed');
max_I = max(max(I_double));
min_I = min(min(I_double));
I_temp = (I_double - min_I)./(max_I - min_I);
imshow(I_temp);
Best,
Iskander
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!