I'm in Java and storing a large number of binary vtkImageData's. I know this is inefficient, and am searching for a better way to store them. Right now I have a hash of the vtkImageData's and a get/put function. Basically I want to mimic this get/put but with better storage. I was thinking one way to do this is to use bitwise logical operations to store the information in the binary masks. For instance, if we have 2 binary images, then we could store that information in 1 vtkImageData using the following pseudo code.<div>
<br></div><div>private static final int IMAGE1_BIT_CHANNEL = 0;</div><div>private static final int IMAGE2_BIT_CHANNEL = 1;</div><div>private vtkImageData storedImage;</div><div><br></div><div>vtkImageData get(String image) {</div>
<div> int channel = image eq "image1" ? IMAGE1_BIT_CHANNEL : IMAGE2_BIT_CHANNEL;</div><div> vtkImageData return = new vtkImageData();</div><div> foreach (pixel in storedImage)</div><div> if (pixel at bit channel)</div>
<div> return[pixel] = 1;</div><div> else</div><div> return[pixel] = 0;</div><div> return return;</div><div>}</div><div><br></div><div>void put(String image, vtkImageData binaryImage) {</div>
<div><div> int channel = image eq "image1" ? IMAGE1_BIT_CHANNEL : IMAGE2_BIT_CHANNEL;</div><div> foreach (pixel in binaryImage)</div><div> if (pixel)</div><div> storedImage at bit in channel = 1;</div>
<div> else</div><div> storedImage at bit in channel = 0;</div></div><div>}</div><div><br></div><div>This could be extended easily for 8 channels for a char image for instance. This operation would have to be very fast though cause it is done often on the UI thread.</div>
<div>1. Is there a way to do this in VTK with Java?</div><div>2. Is this the best scheme for accomplishing my goal?</div><div>3. Is there a better scheme for doing this?</div><div><br></div><div>Thanks.</div>