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, )))
model.add(Conv2D(nb_classes, kernel_size=3, padding = 'same',
                 activation='relu',
                 input_shape=(128,128,1)))
#model.add(MaxPooling2D(pool_size=(2, 2), padding='same'))
model.add(Conv2D(32, kernel_size = 3, activation='relu', padding = 'same'))
#model.add(MaxPooling2D(pool_size=(2, 2), padding='same'))
#model.add(Dropout(0.25))
#model.add(Flatten())
#model.add(Dense(128, activation='relu'))
#model.add(Dropout(0.5))
#model.add(Conv2D(32, (3, 3), activation='relu', padding='same'))

#model.add(UpSampling2D((4,4)))

model.add(Conv2D(nb_classes, (3, 3), activation = 'relu', padding='same'))
#model.add(Dense(10, activation = 'relu', input_shape = (128, 128,)))
model.add(Activation('softmax'))
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.