I have a 3D Image (each pixel contains information for various wavelengths). I draw the image for one wavelength by using

Image[img[[All, All, 100]]] // ImageAdjust

whereas img is my Image. Now I want to extract the Data in a certain ROI. I do so by using the mask tool, but when I copy the mask, I get a fullsize image where the selected mask is white (I selected the following three squares):

enter image description here

How to extract the information from img (fully including the wavelength-dimension) for these regions? I.e. discarding the black areas completely. ImageMultiply doesnt help me, as this would just make those areas black again and not really discarding them.


  • 1
    $\begingroup$ I guess that's "region of interest"? (I had at first thought "return on investment" but clearly that does not go with the question at hand.) $\endgroup$ Dec 1, 2014 at 15:41
  • $\begingroup$ yes region of interest ;) $\endgroup$
    – tim
    Dec 2, 2014 at 7:56

1 Answer 1


I finally found a solution:

mask = (* As seen above, copied from masking tool as a "Image *)
pos = Position[mask // ImageData, 1];
spectra = Extract[img, pos];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.