Proposal Details
Context / Use Case
There is a good global Bathymetric data set called GEBCO that provides the data as downloadable GeoTIFF tiles. These tiles cannot be opened by x/image/tiff today, as the tiff reader only supports the unsigned integer sample format, and the GEBCO tiles are in signed int16 sample format (elevations in the ocean encoded as negative integers in units of feet).
For my own use today, it is simple to fork /x/image and modify tiff to read signed int16 as if it were uint16, and then on accessing pixels in my program just re-interpret, e.g. int16(pixValue.Y). This does require prior knowledge that the file is signed format to do this, and I don't recommend implementing this solution into the tiff reader since it effectively treats unsigned and signed sample format the same, which is incorrect. Additionally, this issue likely applies to more bathymetric data sets, partial and global, in tiff or other image formats, since almost all absolute depth/elevation in feet fits very nicely into the int16 data type. It is possible that there are other medical imaging use cases for signed gray values as well, though I am not familiar with these.
Proposed Changes
I proposing adding 'gray signed 16' color models to see if this is motivating for the standard library or its extensions, with the target of using this addition in the /x/image/tiff package.
- Add a new
color.Color implementation: color.GrayS16
- Add a new
color.Model implementation: color.GrayS16Model
- The conversion to RGBA here could be largely use the logic in
color.Gray16Model
- Add a new
image.Image implementation: image.GrayS16
- Largely similar to
image.Gray16, except:
image.GrayS16.At would return color.GrayS16
- Use
GrayS16At(x, y int) color.GrayS16 method
I am willing to submit Pull Requests with this solution if it seems acceptable, and also acknowledge that making additions to the standard library is not to be taken lightly.
Proposal Details
Context / Use Case
There is a good global Bathymetric data set called GEBCO that provides the data as downloadable GeoTIFF tiles. These tiles cannot be opened by
x/image/tifftoday, as the tiff reader only supports the unsigned integer sample format, and the GEBCO tiles are in signedint16sample format (elevations in the ocean encoded as negative integers in units of feet).For my own use today, it is simple to fork
/x/imageand modifytiffto read signedint16as if it wereuint16, and then on accessing pixels in my program just re-interpret, e.g.int16(pixValue.Y). This does require prior knowledge that the file is signed format to do this, and I don't recommend implementing this solution into the tiff reader since it effectively treats unsigned and signed sample format the same, which is incorrect. Additionally, this issue likely applies to more bathymetric data sets, partial and global, in tiff or other image formats, since almost all absolute depth/elevation in feet fits very nicely into theint16data type. It is possible that there are other medical imaging use cases for signed gray values as well, though I am not familiar with these.Proposed Changes
I proposing adding 'gray signed 16' color models to see if this is motivating for the standard library or its extensions, with the target of using this addition in the
/x/image/tiffpackage.color.Colorimplementation:color.GrayS16color.Modelimplementation:color.GrayS16Modelcolor.Gray16Modelimage.Imageimplementation:image.GrayS16image.Gray16, except:image.GrayS16.Atwould returncolor.GrayS16GrayS16At(x, y int) color.GrayS16methodI am willing to submit Pull Requests with this solution if it seems acceptable, and also acknowledge that making additions to the standard library is not to be taken lightly.