# Training a CNN to convert ellipses into circles

My current project has to do with modeling the effects of blurring/convolution of objects in various imaging processes. Right now, I am starting off with a preliminary, artificial model. I am using Keras to accomplish this.

I create artificial ideal data as a set of circles in random locations in a 128 x 128 image. I then have a routine that takes the coordinates and sizes of these circles as input and replaces the circles with ellipses at the same locations.

I am trying to train a convolutional neural network to perform the inverse of this function, i.e. read the images with ellipses as input and replace them with circles. I create training pairs by grouping these two image types together with the images with ellipses as inputs and the images with circles as outputs.

How can I design a neural network which accomplishes this? Right now, the one that I am using merely returns distorted copies of the images of ellipses instead of outputting images with circles.

I have played around with multiple different CNN structures, as you can see in the commented-out code:

model = Sequential()

#model.add(Dense(10, activation = 'relu', input_shape = (80, 128, 128, )))
activation='relu',
input_shape=(128,128,1)))

#model.add(Dense(10, activation = 'relu', input_shape = (128, 128,)))

• You should rather use classical methods to transform the ellipses. I my opinion it makes no sense to do something like this with neural networks. But it is an interesting task if you want to play around with neural networks. – MachineLearner Aug 9 '19 at 8:02

Use your generated images to train an encoder-decoder that attempts to rebuild the input image. We'll call these pieces the input encoder and ellipse decoder. In parallel, train a second decoder that takes the input encoder (i.e. embedding representation) as input and attempts to rebuild the original circle image. The input encoder + circle decoder can then be used together for scoring out-of-sample observations.

• Thank you! I will try to learn what encoders and decoders are and then implement this as a solution. – 2017Algebraist Jul 10 '19 at 7:52

The principle of your model would be analogous to the one of a Denoising Autoencoder. In this kind of Autoencoders, you train a Network to reconstruct an image from a deteriorated version of it.

You need something similar to that: training a convolutional Autoencoder to "get a circle out of an input ellipse".

You can take a look at this implementation of a Denoising Autoencoder on the Keras website. I think that's a good start.