stretch the edges of any image data areas in python-opencv - python

I'm trying to stretch the edges of the image (duplicate pixels) around data (not transparent) areas in picture.
for example:
before:
after - the red line is only for you to see the difference
note: it's important not to change the dimension of the image, i'ts being used for geographical needs.
I would like to hear any ideas or suggestions from you, code snippets will be welcomed.
thank you!

This problem is called image outpainting and You can see very advanced deep learning based solutions in papers on paperswithcode.com. Current state-of-art is given by Basile Van Hoorick in work Image Outpainting and Harmonization using Generative Adversarial Networks. Code with possibility of usage is placed in his github profile. See Usage section on github to know how to use it.
There are 3 models available to use in Pretrained models section:
G_art.pt: Artistic
G_nat.pt: Natural
G_rec.pt: Reconstruction loss only (no adversarial loss)
I believe You'll have to use transfer learning to train and use this architecture in Your use case.

Related

Tensorflow should I crop objects from the images for better accuarcy?

I am new to tensorflow and I could not find an answer for my question.
I am trying to make a simple program what recognises the type of van from the picture. I downloaded about 100 pictures for my dataset from each category.
My question is should I crop the pictures so only the van is visible on the picture?
Or should I use the original picture with the background for better accuracy?
The short answer is yes it will, but there is a lot more to consider when asking that question. For example, when I use this model how will the images look? Will there be someone to manually crop these images and then use the model or will someone be taking these photos off of a cell phone using an app? A core concept of Machine learning is to have the images in the production environment as close to the training data as possible so that your performance in production doesn't change.
If you're just trying to learn I would highly recommend trying to build a network on MNIST or lego bricks dataset before you try on your own images as if you get stuck on either there are a lot of great resources available :). Also, consider setting aside 10 images as a Test set so that you can evaluate model performance. And third, Tensorflow has a built-in image dataset generator which will greatly improve your model performance on a small dataset like this. The TensorFlow image dataset generator can scale, rotate, flip and, zoom your images which will produce huge improvements in model accuracy.
Good luck!

Binary image classifier for logos

I am currently looking for a possibly fast way to create (or use an already existing) classifier for images. The main goal is to classify the images whether they are (mainly) a logo or not. This means that I am not interested in recognizing the brand/name of the company. But instead the model would have to tell how possible it is that the image is a logo.
Does such a categorizer already exist? And if not, is there any possible solution to avoid neural networks for this task?
Thanks in advance.
I am not sure about the existence of this project, but I have a couple of ideas that can work for this without neural networks. I think as a convention neural networks would be much easier but I think it might be done K-means algorithm or by a clustering algorithm. I have imagined like if logo data are in the same area and image data are in another same area, they can be clustered.However, I haven't done it sth like that before but theoretically, it seems logical
As you have seen there isn't a y label in our algorithm.

simple way to detect street area in google map images (aerial images)

im trying to detect the area of the street in image without any deep learning method.
say i have this image:
i am looking for any simple method to detect street portion of the image like the following:
now i know this might not be very accurate, and accuracy is not the problem at all , i am trying to achieve this without using any deep learning method.
Hough line can give direct straight line measure. but i don't thin it will give you exactly what you want. As shown below
You need a lot more complicated algorithms such as deep sematic segmentation model. and train based on that.
Even you don't like deep learning. traditional algo such as variational analysis, SVM learning or adaboost is also very complicated and you wont be able to use it easily. You need to have mucher deeper understanding on those topic.
if you really want you can start with variational analysis, active contour model, snake energy for extracting the road first. This variational analysis is proven to be working for a complex scenes and extract a particular model as shown in the image below. your road is the empty low gradient region and all building tree nearby are high gradient responses that you don't want.
My suggestion is to make your life easier by using pre trained model and extra the surface model. Download, run python script. that's all
There are a few open-source implementations that you can try such as this
https://github.com/ArkaJU/U-Net-Satellite
https://github.com/Paulymorphous/Road-Segmentation
https://github.com/avanetten/cresi
Based on the predicted mask. then you can get production accurately as shown below
This would be the result that you are looking for
Regards
Shenghai Yuan

How to understand/debug/visualize U-Net segmentation results

I am training a U-Net architecture to for a segmentation task. This is in Python using Keras. I have now run into an issue, that I am trying to understand:
I have two very similar images from a microscopy image series (these are consecutive images), where my current U-Net model performs very good on one, but performs extremely poor on the immediately following one. However, there is little difference between the two to the eye and the histograms also look very much alike. Also on other measurements the model performs great across the whole frame-range, but then this issue appears for other measurements.
I am using data-augmentation during training (histogram stretching, affine transformation, noise-addition) and I am surprised that still the model is so brittle.
Since the U-Net is still mostly a black-box to me, I want to find out steps I can take to better understand the issue and then adjust the training/model accordingly.
I know there are ways to visualize what individual layers learn (e.g. as discussed F. Chollets book see here) and I should be able to apply these to U-Nets, which is fully convolutional.
However, these kinds of methods are practically always discussed in the realm of classifying networks - not semantic segmentation.
So my question is:
Is this the best/most direct approach to reach an understanding of how U-Net models attain a segmentation result? If not, what are better ways to understand/debug U-Nets?
I suggest you use the U-Net container on NGC https://ngc.nvidia.com/catalog/resources/nvidia:unet_industrial_for_tensorflow
I also suggest you read this: Mixed Precision Training: https://arxiv.org/abs/1710.03740
https://developer.nvidia.com/blog/mixed-precision-training-deep-neural-networks/
Let me know how you are progressing and if any public repo, happy to have a look

Processing Image for machine learning

I started to do the medical image analysis for a project.
In this project I have images of human kidney(s) with and without stones. The aim is to predict if the given new image has stone or not.
I chose the KNN classifier model to do classification but I do not understand the image processing. I have some knowledge on segmentation. I can convert it into array for processing but I need some pointers to understand the process.
Image - https://i.stack.imgur.com/9FDUM.jpg
For image classification I would recommend you to use pre-trained neural networks like Resnet etc.
Frameworks like Tensorflow give a good API to re-train pre-trainined neural networks for a different use-case.
You can follow below link:
https://www.tensorflow.org/hub/tutorials/image_retraining
Image Processing is done to convert the digital images into a format which would be easier for a computer to calculate statistics on.
Images do not always contain the necessary information, there is noise and lots of unnecessary background information available in the image which won't be required for a specific purpose.
The Goal of processing an image is to extract the region of interest from the whole image.
Along with this various enhancements are done to the image so that we get features that are useful in calculating inferences
Processing an image consists of various image enhancement techniques and segmentation and other stuff like maybe a histogram equalization which in the end would be used to extract features. Doing this processing yields better features generally.
Also Image processing in itself is a vast topic. I recommend you read about it in papers from Google scholar

Categories