jip
2014-04-28 16:47:29 UTC
Hello,
I meet some problems with labeled.remove_regions_where(), with an error
message:
<Loading Image...>
mahotas.labeled.remove_regions: labeled is not as expected
The things work fine with a model example running in an ipython cell
import mahotas as mh
labarray = np.zeros((9,9), dtype=int16)
labarray[0:1,0:2] = 1
labarray[3:7,1:4] = 2
labarray[2:5,5:8] = 3
labarray, _ = mh.labeled.label(labarray)
labsiz = mh.labeled.labeled_size(labarray)
copy = mh.labeled.remove_regions_where(labarray, labsiz < 7)
mh.labeled.relabel(copy, inplace=True)
subplot(121)
title(labarray.dtype)
imshow(labarray, cmap=plt.cm.jet, interpolation='nearest')
subplot(122)
title(shape(copy))
imshow(copy, cmap=plt.cm.jet, interpolation='nearest')
The things goes wrong with this image obtained after watershed:
I checked its type, size, densitometric plot too:
<Loading Image...>
uint8 (38, 30) [ 0 0 0 0 0 0 25 25 25 25 32 32 0 0 0 0 30 30 0 0]
Now with the following code:
labsize2 = mh.labeled.labeled_size(chr_label)
ctd_elem = mh.labeled.remove_regions_where(chr_label, labsize2 < 4)
mh.labeled.relabel(ctd_elem, inplace=True)
there the following message:
--------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-40-7252923a5ad4> in <module>()
1 labsize2 = mh.labeled.labeled_size(chr_label)
----> 2 ctd_elem = mh.labeled.remove_regions_where(chr_label, labsize2 < 4)
3 mh.labeled.relabel(ctd_elem, inplace=True)
/usr/local/lib/python2.7/dist-packages/mahotas-1.1.0-py2.7-linux-i686.egg/mahotas/labeled.pyc in remove_regions_where(labeled, conditions, inplace)
208 '''
209 regions, = np.where(conditions)
--> 210 return remove_regions(labeled, regions, inplace=inplace)
211
212
/usr/local/lib/python2.7/dist-packages/mahotas-1.1.0-py2.7-linux-i686.egg/mahotas/labeled.pyc in remove_regions(labeled, regions, inplace)
176 your label image.
177 '''
--> 178 _check_array_labeled(labeled, labeled, 'remove_regions')
179 regions = np.asarray(regions, dtype=np.intc)
180 regions = np.unique(regions)
/usr/local/lib/python2.7/dist-packages/mahotas-1.1.0-py2.7-linux-i686.egg/mahotas/labeled.pyc in _check_array_labeled(array, labeled, funcname)
359 def _check_array_labeled(array, labeled, funcname):
360 if labeled.dtype != np.intc or not labeled.flags.carray:
--> 361 raise ValueError('mahotas.labeled.%s: labeled is not as expected' % funcname)
362 if array.shape != labeled.shape:
363 raise ValueError('mahotas.labeled.%s: `array` is not the same size as `labeled`' % funcname)
ValueError: mahotas.labeled.remove_regions: labeled is not as expected
Thank you for your advices.
Jean-Patrick
I meet some problems with labeled.remove_regions_where(), with an error
message:
<Loading Image...>
mahotas.labeled.remove_regions: labeled is not as expected
The things work fine with a model example running in an ipython cell
import mahotas as mh
labarray = np.zeros((9,9), dtype=int16)
labarray[0:1,0:2] = 1
labarray[3:7,1:4] = 2
labarray[2:5,5:8] = 3
labarray, _ = mh.labeled.label(labarray)
labsiz = mh.labeled.labeled_size(labarray)
copy = mh.labeled.remove_regions_where(labarray, labsiz < 7)
mh.labeled.relabel(copy, inplace=True)
subplot(121)
title(labarray.dtype)
imshow(labarray, cmap=plt.cm.jet, interpolation='nearest')
subplot(122)
title(shape(copy))
imshow(copy, cmap=plt.cm.jet, interpolation='nearest')
The things goes wrong with this image obtained after watershed:
I checked its type, size, densitometric plot too:
<Loading Image...>
uint8 (38, 30) [ 0 0 0 0 0 0 25 25 25 25 32 32 0 0 0 0 30 30 0 0]
Now with the following code:
labsize2 = mh.labeled.labeled_size(chr_label)
ctd_elem = mh.labeled.remove_regions_where(chr_label, labsize2 < 4)
mh.labeled.relabel(ctd_elem, inplace=True)
there the following message:
--------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-40-7252923a5ad4> in <module>()
1 labsize2 = mh.labeled.labeled_size(chr_label)
----> 2 ctd_elem = mh.labeled.remove_regions_where(chr_label, labsize2 < 4)
3 mh.labeled.relabel(ctd_elem, inplace=True)
/usr/local/lib/python2.7/dist-packages/mahotas-1.1.0-py2.7-linux-i686.egg/mahotas/labeled.pyc in remove_regions_where(labeled, conditions, inplace)
208 '''
209 regions, = np.where(conditions)
--> 210 return remove_regions(labeled, regions, inplace=inplace)
211
212
/usr/local/lib/python2.7/dist-packages/mahotas-1.1.0-py2.7-linux-i686.egg/mahotas/labeled.pyc in remove_regions(labeled, regions, inplace)
176 your label image.
177 '''
--> 178 _check_array_labeled(labeled, labeled, 'remove_regions')
179 regions = np.asarray(regions, dtype=np.intc)
180 regions = np.unique(regions)
/usr/local/lib/python2.7/dist-packages/mahotas-1.1.0-py2.7-linux-i686.egg/mahotas/labeled.pyc in _check_array_labeled(array, labeled, funcname)
359 def _check_array_labeled(array, labeled, funcname):
360 if labeled.dtype != np.intc or not labeled.flags.carray:
--> 361 raise ValueError('mahotas.labeled.%s: labeled is not as expected' % funcname)
362 if array.shape != labeled.shape:
363 raise ValueError('mahotas.labeled.%s: `array` is not the same size as `labeled`' % funcname)
ValueError: mahotas.labeled.remove_regions: labeled is not as expected
Thank you for your advices.
Jean-Patrick
--
You received this message because you are subscribed to the Google Groups "pythonvision" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pythonvision+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "pythonvision" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pythonvision+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org
For more options, visit https://groups.google.com/d/optout.