1
$\begingroup$

I want to design and train a neural network for the automatic recognition of the edges, in some microscopic images. I am using Keras for a start, I may consider PyTorch later.

The structure of the images is rather simple, with some dark areas, and some clear areas, relatively easy to distinguish, and the task is to select the pixels of the contour between dark and clear areas. The transition between dark and clear is gradual, so my result is not a single line of edge pixels, but rather a 10 or 15 wide ribbon of edge pixels.

I have manually annotated 200-something images, so for each image I have another image, of the same size, where the pixels of the contours are black, and all the other pixels are white.

I have seen many tutorials on how to design, compile and fit a model (a neural network), and then how to test it, using the manually annotated data.

However, most of the tutorials work on problems of classification, where the number of neurons in the output layer is the number of categories.

My problem is not a problem of classification, and ideally my output should be an image of the same size of the input.

So, here is my question:

What is the best way to design the output layer? Is a layer with a number of neurons equal to the number of pixels the best idea? Or this is a waste, and there is a more efficient way?


Addendum

The images are "easy", but it is still difficult to find the contour pixels, so it is worth using the machine learning approach.

The transition between dark and clear is a little gradual, so my result is not a single line of pixels on the edge, but rather a band, a 10 or 15 wide ribbon of edge pixels.

Since I am after a ribbon of pixels, my categories should be "edge" and "not-edge". If I use the categories "dark pixels" and "clear pixels", and then numerically find the pixels between the two areas I do not get the "ribbon" result, which I need.

$\endgroup$
0
$\begingroup$

You probably don't require the use of artificial intelligence for your task, it seems quite 'easy' to do, check out openCV library, it probably has a function that does the job without AI (here is one for example).

The use of IA network may get you a more accurate result tho, so I would do it using classic image segmentation (U-Net is one of the most common architecture used), with 2 classes : one for the darker areas, and one for the lighter areas. Once you have your image with 2 classes, lighter and darker ares, apply an algorithm that detect if a Pixel is an edge to get your result.

$\endgroup$
3
  • $\begingroup$ Thank you for your answer! The transition between dark and clear is a little gradual, so my result is not a single line of pixels on the edge, but rather a band, a 10 or 15 wide ribbon of edge pixels. Since I am after a ribbon of pixels, my categories should be "edge" and "not-edge". If I use the categories "dark pixels" and "clear pixels", and then numerically find the pixels between the two areas I do not get the "ribbon" result, which I need. $\endgroup$ – Fabio Jun 8 at 4:12
  • 1
    $\begingroup$ Right, then it is worth giving U-Net a try with 2 classes corresponding to 'edge' and 'not-edge'. Problem is you do not have many labelled datas, but I remember training a small U-Net on 300 images and still got a pretty decent result, so it seems possible to train a U-Net with your dataset (I feel like a didn't use transfer learning in my case, but I'm not sure about it). $\endgroup$ – Ubikuity Jun 8 at 12:10
  • $\begingroup$ I am still working on it, but I found a good tutorial, for U-Net, and it is indeed the answer to my question, thank you! I am confident that I will manage to get it running. If needed, I can manually annotate (many) more images. $\endgroup$ – Fabio Jun 10 at 9:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.