Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preserve 8-bit, 0-255 values as native storage for spectral data #18

Open
2 tasks
jywarren opened this issue Apr 21, 2016 · 0 comments
Open
2 tasks

preserve 8-bit, 0-255 values as native storage for spectral data #18

jywarren opened this issue Apr 21, 2016 · 0 comments

Comments

@jywarren
Copy link
Member

jywarren commented Apr 21, 2016

Currently, we use the expression parseInt(line[1] / 2.55)/100 to save image data, which scales it to 0-100%.

In JSON:

_spectrum.average.push({ y: parseInt(line.average / 2.55)/100, x: x })
if (line.r != null) _spectrum.red.push( { y: parseInt(line.r / 2.55)/100, x: x })
if (line.g != null) _spectrum.green.push({ y: parseInt(line.g / 2.55)/100, x: x })
if (line.b != null) _spectrum.blue.push( { y: parseInt(line.b / 2.55)/100, x: x })

and from arrays:

_spectrum.average.push({ y: parseInt(line[1] / 2.55)/100, x: x })
_spectrum.red.push( { y: parseInt(line[1] / 2.55)/100, x: x })
_spectrum.green.push( { y: parseInt(line[1] / 2.55)/100, x: x })
_spectrum.blue.push( { y: parseInt(line[1] / 2.55)/100, x: x })

@Stoft1 has suggested strongly that we make native data storage match original data, which would be 8-bit, 0-255. That'd mean removing the scaling from those lines, and from the matching encodeJSON code at:

average: +(_spectrum.average[i].y * 255).toPrecision(_spectrum.sigFigIntensity),
r: +(_spectrum.red[i].y * 255).toPrecision(_spectrum.sigFigIntensity),
g: +(_spectrum.green[i].y * 255).toPrecision(_spectrum.sigFigIntensity),
b: +(_spectrum.blue[i].y * 255).toPrecision(_spectrum.sigFigIntensity)

Tests would then have to be refactored to look for values in 0-255. We could stick to integer values in sigFigIntensity at:

sigFigIntensity: 4, // since image channel data is 0-255, or 000.4-100.0

On SpectralWorkbench.org, lots of data is stored scaled (not 8-bit). So we'd want to have an easy converter in case people want to compare across.

Update:

  • we can create an attribute called spectrum.native8bit which is set to true for all data that does this, so that legacy data will not have this default.
  • we can make a spectrum.scaleData() method which checks for spectrum.native8bit and scales data if it is not true.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant