dkriegner / micro-flakes

https://dkriegner.github.io/micro-flakes/
GNU General Public License v3.0
0 stars 0 forks source link

Converting image #17

Closed ji-ze closed 12 months ago

ji-ze commented 1 year ago

https://github.com/dkriegner/micro-flakes/blob/8ee5b7d330160a3ebd19f979080583e6dcbbc28e/Detector/find_objects.py#L337-L340

ji-ze commented 1 year ago

I found on Stack Overflow, but it doesn't work.

dkriegner commented 1 year ago

This works for me

import cv2
cvImg = cv2.imread('test.png')
cvImg2 = cv2.cvtColor(cvImg, cv2.COLOR_BGR2RGB)
from PIL import Image
pilimg = Image.fromarray(cvImg2)

what error do you get?

dkriegner commented 1 year ago

One other comment to this code snippet: self.object_filename[:-4] looks like you want to get rid of the file extension. for this exists a library function os.path.splitext which I would recommend to use instead. imagine someone uses a tiff file which might have a longer extension. your version would fail but the library function will handle it just fine.

ji-ze commented 1 year ago

The problem is in a different place:

image
ji-ze commented 1 year ago

contourI and contourII are 0.

ji-ze commented 1 year ago

The problem was with the function for the measure area. It assumed a black and white image, but got an RGB image.

dkriegner commented 12 months ago

so its solved? we can close the issue?