Convert PIL image to skimage?
I have an image loaded in my code (very long and unnecessary, will not be posted here) that I need to work with skimage to detect blobs in the image. However, for some reason, all the images and attempts I have used do not work.
The image is modified by PIL in the code above so that the objects I'm trying to find are only white (255, 255, 255) and all others are black. This code should only identify their positions. I tried a lot of different things to get this to work (converting them to a numpy array, not converting them to ect of a numpy array.)
I follow these instructions: http://scikit-image.org/docs/dev/auto_examples/plot_blob.html for the basics, but this is not really a tutorial but an example.
I think the rgb2gray function is problematic as it returns nothing but 0, while printing (numpy.array (img)) returns values between 0 and 1, indicating that information loss occurs when rgb2gray is called.
Here's the code that seems problematic:
img_gray = rgb2gray(numpy.array(img)) # Convert to numpy array for skimage print(img_gray) print(numpy.array(img)) img_blobs = blob_doh(img_gray, threshold=0.01, max_sigma=500) print(img_blobs)
How can I fix this?
This is what each of the images, arrays and lists prints:
 [ ] [ ] ..., [ ] [ ] [ ]] [ ] [ ] [ ] ..., [ ] [ ] [ ]] [ ] [ ] [ ] ..., [ ] [ ] [ ]] [ ] [ ] [ ] ..., [ ] [ ] [ ]] ..., [ ] [ ] [ ] ..., [ ] [ ] [ ]] [ ] [ ] [ ] ..., [ ] [ ] [ ]] [ ] [ ] [ ] ..., [ ] [ ] [ ]]] 
source to share
This will read image files (using PIL) into an image:
from skimage import io img = io.imread("./path/to/image.png")
Since you've already read the images and wanted to do the data transformation yourself, you can see how the plugin authors did it: https://github.com/scikit-image/scikit-image/blob/master/skimage/io/_plugins/pil_plugin. py
source to share