luispedro / mahotas

Computer Vision in Python
https://mahotas.rtfd.io
Other
844 stars 148 forks source link

haralick error using python3.4 munmap_chunk(): invalid pointer: 0x0000000001fb37f0 #72

Closed erik78se closed 8 years ago

erik78se commented 8 years ago

I'm getting the following error when I'm trying to extract haralick features from an envi image:

def calculate(self, image, region, training=False):

        # Read out subregion and convert it to a float and normalize

        print(region.astype('int'))

        img = image.read_subregion(*region.astype('int32'), use_memmap=False).astype(np.dtype('float'))/(2**16 - 1)

        # Calculate principle component analysis and reduce to the top 5 eigenvalues
        pc = PCA(img).reduce(num=5)

        # Transform original data based on PCA analysis and dimensional reduction
        pc_img = pc.transform(img)

        # Scale up to 64 grey levels and convert back to integer type
        pc_img = np.transpose((pc_img*64).astype(np.dtype('int8')))

        # Preallocate texture feature array
        texture = np.zeros((4, 13), dtype=np.float)

        # Calculate Haralick texture features and add them to the array
        for band in pc_img:
            texture += haralick(band)

The error message: *** Error inpython': munmap_chunk(): invalid pointer: 0x00000000017a0930 *\ Aborted (core dumped)`

My environment is:

Ubuntu 15.10 (64bit)
Python 3.4.3+
Cython-0.23.5-py3.4
mahotas-1.4.1-py3.4
numpy-1.11.0-py3.4
erik78se commented 8 years ago

My misstake dtype should have been uint8. That might be agood thing to make some test for since using int8 will fail on you.

pc_img = np.transpose((pc_img_64).astype(np.dtype('_uint8*')))

luispedro commented 8 years ago

This is a bona fide bug: mahotas should never crash your interpreter even if you pass it the wrong arguments. I will fix it soon.

Thank you.