# features extract with .png image

**URL:** <https://discourse.slicer.org/t/features-extract-with-png-image/23049>\
**Category:** Radiomics\
**Created:** [April 20, 2022, 11:29am UTC](https://discourse.slicer.org/t/features-extract-with-png-image/23049 "2022-04-20T11:29:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JY\_C](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jy_c/32/15039_2.png) [@JY\_C](https://discourse.slicer.org/u/JY_C)\
**Post date:** [April 20, 2022, 11:29am UTC](https://discourse.slicer.org/t/features-extract-with-png-image/23049/1 "2022-04-20T11:29:43Z")

</div>

I want to extract features with HE image, and I save the tiles with .png file. Here is my code:

image = sitk.ReadImage(‘test.png’) # dim=(1024, 1024, 3)

mask\_arr = np.ones(image.GetSize()[::-1])  
mask = sitk.GetImageFromArray(mask\_arr)

firstOrderFeatures = firstorder.RadiomicsFirstOrder(image, mask)

Traceback (most recent call last):  
File “/data/chenzhi/.pycharm\_helpers/pydev/pydevd.py”, line 1483, in \_exec  
pydev\_imports.execfile(file, globals, locals) # execute the script  
File “/data/chenzhi/.pycharm\_helpers/pydev/\_pydev\_imps/\_pydev\_execfile.py”, line 18, in execfile  
exec(compile(contents+"\n", file, ‘exec’), glob, loc)  
File “/data/chenzhi/Chenjy/Pathomics/paper\_repetition/features\_extract.py”, line 20, in   
firstOrderFeatures = firstorder.RadiomicsFirstOrder(image, mask, voxelBased=False)  
File “/data/chenzhi/.conda/envs/Chenjy/lib/python3.7/site-packages/radiomics/firstorder.py”, line 37, in **init**  
self.discretizedImageArray = self.\_applyBinning(self.imageArray.copy())  
File “/data/chenzhi/.conda/envs/Chenjy/lib/python3.7/site-packages/radiomics/base.py”, line 115, in \_applyBinning  
matrix, \_ = imageoperations.binImage(matrix, self.maskArray, \*\*self.settings)  
File “/data/chenzhi/.conda/envs/Chenjy/lib/python3.7/site-packages/radiomics/imageoperations.py”, line 155, in binImage  
binEdges = getBinEdges(parameterMatrix[parameterMatrixCoordinates], \*\*kwargs)  
File “/data/chenzhi/.conda/envs/Chenjy/lib/python3.7/site-packages/radiomics/imageoperations.py”, line 116, in getBinEdges  
minimum = min(parameterValues)  
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

---

<div class="post-metadata">

**Author:** ![JoostJM](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/joostjm/32/1091_2.png) [@JoostJM](https://discourse.slicer.org/u/JoostJM)\
**Post date:** [May 3, 2022, 7:34am UTC](https://discourse.slicer.org/t/features-extract-with-png-image/23049/2 "2022-05-03T07:34:35Z")

</div>

Hello @JY_C,

There are 2 main problems with your code. The first one has to do with your input image. .png yields a color image, meaning it has 3 color channels. PyRadiomics requires grayscale (i.e. 1 value per pixel). There are many other topic reporting this ‘issue’ and how to fix it.

The second ‘problem’ is that you are using the FirstOrder class directly. While this will yield results, nearly all preprocessing is skipped. It is better to use the featureextractor module and enable only ‘firstorder’.
