I'm working on image segmentation using caffe, sciki-image, opencv and matplotlib/pyplot. This work involves some image resizing. Essentially, after I've loaded and resized the image:
put_image = caffe.io.load_image(os.path.join(source_dir, pix)
input_image = caffe.io.resize_image(input_image, (600,500), interp_order=3)
I do quite a bit of processing. Everything worked well until I decided to add some contours to the image:
fig, ax = plt.subplots(1, 1)
ax.imshow(image2)
...
ax.fill(vald[:, 0], vald[:, 1], fill=False, color='red', linewidth=1)
where vald
is some array and image2
is some output from processed input_image
After saving it
fig.savefig(save_dir + str(idx) + ".png", bbox_inches = 'tight')
I get something like this, which is essentially a cropped version of the original image
So of course my first reaction was to just crop the image and resize it afterwards, but it turned out to lose much of its quality (resolution deteriorated). I tried following suggestions from here and here, but didn't get any improvement either.