0

I would like to know how to change a pixel value for the label map.

This is my initial approach. Unfortunately, the changes are not reflected in the canvas.

X.volume.prototype.SetPixelLabelMap = function(i, j, k, value){
  this._labelmap._IJKVolume[k][j][i] = value;

  var color = this._labelmap._colortable._map.get(value);

  var changeRawData = function(rawdata, pos){
    for(var n = 0; n < 4; n++){
      rawdata[pos + n] = color[n + 1];
    }
  }

  var dim = this._dimensions;
  //in Z axis height is j width is i, the fast moving direction is the height
  if(this._labelmap._children[2]._children[k]){
    changeRawData(this._labelmap._children[2]._children[k]._texture._rawData, (dim[0]*i + j)*4);
  }

  //in Y axis height is k width is i
  if(this._labelmap._children[1]._children[j]){
    changeRawData(this._labelmap._children[1]._children[j]._texture._rawData, (dim[0]*i + k)*4);
  }
  
  if(this._labelmap._children[0]._children[i]){
    //in X axis height is j width is k
    changeRawData(this._labelmap._children[0]._children[i]._texture._rawData, (dim[2]*k + j)*4);
  }

}
Juan
  • 806
  • 1
  • 8
  • 15
  • This post is related to the following [git issue](https://github.com/xtk/X/issues/166#issuecomment-69914251) `The volume.sliceInfoChanged(0);` does not work – Juan Jan 15 '15 at 01:26
  • can you setup a jsfiddle or a codepen with a demo which illustrates the issue? – Nicolas Jan 15 '15 at 07:04

1 Answers1

0

You can change it using

dims = volume.labelmap.dimensions;
zm = dims[0];
ym = dims[1];
xm = dims[2];
  for (var x = 0; x < xm; x++)
    for (var y = 0; y < ym; y++)
      for (var z = 0; z < zm; z++)
        volume.labelmap.$[x][y][z] = 5; // some number
//volume.labelmap.modified();
volume.sliceInfoChanged(0);
volume.sliceInfoChanged(1);
volume.sliceInfoChanged(2);

JSFiddle

mab
  • 2,658
  • 26
  • 36
  • I tried this before. I want to change some pixels only, this jsfiddle works because the slicing of the raw data is done afterwards. I'm trying to create a "brush" tool to edit some pixels only. – Juan Feb 12 '15 at 02:37