UTokyo-FieldPhenomics-Lab / EasyIDP

A handy tool for dealing with region of interest (ROI) on the image reconstruction (Metashape & Pix4D) outputs, mainly in agriculture applications
https://easyidp.readthedocs.io/en/latest/
MIT License
46 stars 6 forks source link

cvtools.imarray_crop turn 0-1 float rgb to blank uint8 #62

Closed HowcanoeWang closed 1 year ago

HowcanoeWang commented 1 year ago

>>> rotated
array([[[0.31690149, 0.38752052, 0.14294289],
        [0.3404107 , 0.41297721, 0.16013014],
        [0.38506028, 0.4331061 , 0.17238887],
        ...,
        [0.67001947, 0.70273325, 0.44726555],
        [0.71262498, 0.74353751, 0.49159185],
        [0.63883647, 0.66216885, 0.41865424]],
>>> rotated_geotiff_imarray, _ = idp.cvtools.imarray_crop(rotated, roi_geotiff_offseted.astype(int))
>>> plt.imshow(rotated_geotiff_imarray)

image

>>> rotated_geotiff_imarray[:,:,0]
array([[0, 0, 0, ..., 0, 0, 0],
       [0, 0, 0, ..., 0, 0, 0],
       [0, 0, 0, ..., 0, 0, 0],
       ...,
       [0, 0, 0, ..., 0, 0, 0],
       [0, 0, 0, ..., 0, 0, 0],
       [0, 0, 0, ..., 0, 0, 0]], dtype=uint8)

Can be fixed only if the input image type is uint8

>>> rotated = (rotated * 255).astype(np.uint8)