How I predict all the targets on my tiff image using my trained regression model - geolocation

i'm running a regression to predict biophysical parameters on Raster image bands.
I extracted the pixels values in each point of samples, I managed to predict in the same points with multiples non linear regression models.
My question is how can I predict the parameters of all the pixels in my study area using my trained model and how I plot it on my raster with keeping the géo-localisation?
NOTE : I can import the bands with Rasterio or gdal but how to get out with a full prediction?
Thank you in advance.

Related

Image enhancement before CNN helpful?

I have a Deep learning model ( transfer learning based in keras) to do regression problem on medical images. Does it help or have any logical idea or doing some image enhancements like strengthening the edges or doing histogram equalization before feeding the inputs to the CNN?
It is possible to train model accurately by using something you told.
For training CNN model with data, they almost use image augmentation in pre-processing phase.
There are list usually used in augmentation.
color noise
transform
rotate
whitening
affine
crop
flip
etc...
You can refer to here

HOG vector size and dimension

I am having problem to understand about size of HOG feature vector...
scene: I took a 286x286 image.Then I calculated HOG for 8x8 patch each.Mean I got 8x8x2=128 numbers represented by a 9 bin histogram for each patch.so can I say this 9 bin histogram as a 9 dimensional vector?.After,total number of patch to estimate HOG in whole image was approx. 1225(since I have square matrix I estimated total patch by squaring(286/8)=35)).I iterated 1225 patches and calculated 9 bin histogram for each.(I didn't applied 16x16 block normalization) After that concatenating all vector together I obtained 1225x9=11,025 sized HOG of whole image.
question:
1.Then is is right to say I obtained 11,025 dimension of an HOG vector in given image?
2.Am I going in right direction?(if I opt for classification via neural network)
3.Is this concatenated HOG feature can directly feeded to PCA for dimension reduction?or need further more preprocessing?(in genral not in advance)
Thank you in advance!
Yes
Probably not. What are you trying to do? For example, if you are doing classification, you should use bag-of-words (actually, you should stop using HOG and try deep learning). If you are doing image retrieval/matching, you should compute HOG feature for local patches.
You can almost always use PCA for dimensionality reduction for your features, even for 128 dimensional SIFT.

Poor performance on digit recognition with CNN trained on MNIST dataset

I trained a CNN (on tensorflow) for digit recognition using MNIST dataset.
Accuracy on test set was close to 98%.
I wanted to predict the digits using data which I created myself and the results were bad.
What I did to the images written by me?
I segmented out each digit and converted to grayscale and resized the image into 28x28 and fed to the model.
How come that I get such low accuracy on my data set where as such high accuracy on test set?
Are there other modifications that i'm supposed to make to the images?
EDIT:
Here is the link to the images and some examples:
Excluding bugs and obvious errors, my guess would be that your problem is that you are capturing your hand written digits in a way that is too different from your training set.
When capturing your data you should try to mimic as much as possible the process used to create the MNIST dataset:
From the oficial MNIST dataset website:
The original black and white (bilevel) images from NIST were size
normalized to fit in a 20x20 pixel box while preserving their aspect
ratio. The resulting images contain grey levels as a result of the
anti-aliasing technique used by the normalization algorithm. the
images were centered in a 28x28 image by computing the center of mass
of the pixels, and translating the image so as to position this point
at the center of the 28x28 field.
If your data has a different processing in the training and test phases then your model is not able to generalize from the train data to the test data.
So I have two advices for you:
Try to capture and process your digit images so that they look as similar as possible to the MNIST dataset;
Add some of your examples to your training data to allow your model to train on images similar to the ones you are classifying;
For those still have a hard time with the poor quality of CNN based models for MNIST:
https://github.com/christiansoe/mnist_draw_test
Normalization was the key.

Training HOG-linear svm base on TUD-brussel data set

is there anyone ever tried to train an HOG-liner svm pedestrian detector base on The TUD-brussel dataset(which is introduced from this website):
https://www.mpi-inf.mpg.de/departments/computer-vision-and-multimodal-computing/research/people-detection-pose-estimation-and-tracking/multi-cue-onboard-pedestrian-detection/
I tried to implement it on opencv through visual studio 2012. I cropped positive samples from the original positive images base on their annotations(about 1777 samples for total). Negative samples was cropped from original negative images randomly, 20 samples for each image(about 3840 samples for total).
I also adapted two round bootstrapping(checking for hardexamples and retrain) to improve its performance. However, the test result for this detector on TUD-brussel was awful, about 97% miss rate when FPPG(false positive per image) equals to 1. I found another paper which achieved a reasonable result when trainning on TUD-brussel with HOG(on Figure3(a)):
https://www1.ethz.ch/igp/photogrammetry/publications/pdf_folder/walk10cvpr.pdf.
Is anybody have any idea on training HOG+linear SVM on TUD-brussel?
I have to face with a similar situation recently.I developed an image classifier with hog and linear svm in python using pycharm.Problem i faced was it took lot of time to train.
Solution:
Simple I resized each image to 250*250.it really incresed performance in my situation
Resize each image
convert to gray scale
find PCA
flat that and append it to training list
append labels to training labels
for file in listing1:
img = cv2.imread(path1 + file)
res=cv2.resize(img,(250,250))
gray_image = cv2.cvtColor(res, cv2.COLOR_BGR2GRAY)
xarr=np.squeeze(np.array(gray_image).astype(np.float32))
m,v=cv2.PCACompute(xarr)
arr= np.array(v)
flat_arr= arr.ravel()
training_set.append(flat_arr)
training_labels.append(1)
Now Training
trainData=np.float32(training_set)
responses=np.float32(training_labels)
svm = cv2.SVM()
svm.train(trainData,responses, params=svm_params)
svm.save('svm_data.dat')

Feeding HOG into SVM: the HOG has 9 bins, but the SVM takes in a 1D matrix

In OpenCV, there is a CvSVM class which takes in a matrix of samples to train the SVM. The matrix is 2D, with the samples in the rows.
I created my own method to generate a histogram of oriented gradients (HOG) off of a video feed. To do this, I created a 9 channeled matrix to store the HOG, where each channel corresponds to an orientation bin. So in the end I have a 40x30 matrix of type CV_32FC(9).
Also made a visualisation for the HOG and it's working.
I don't see how I'm supposed to feed this matrix into the OpenCV SVM, because if I flatten it, I don't see how the SVM is supposed to learn a 9D hyperplane from 1D input data.
The SVM always takes in a single row of data per feature vector. The dimensionality of the feature vector is thus the length of the row. If you're dealing with 2D data, then there are 2 items per feature vector. Example of 2D data is on this webpage:
http://www.csie.ntu.edu.tw/~cjlin/libsvm/
code of an equivalent demo in OpenCV http://sites.google.com/site/btabibian/labbook/svmusingopencv
The point is that even though you're thinking of the histogram as 2D with 9-bin cells, the feature vector is in fact the flattened version of this. So it's correct to flatten it out into a long feature vector. The result for me was a feature vector of length 2304 (16x16x9) and I get 100% prediction accuracy on a small test set (i.e. it's probably slightly less than 100% but it's working exceptionally well).
The reason this works is that the SVM is working on a system of weights per item of the feature vector. So it doesn't have anything to do with the problem's dimension, the hyperplane is always in the same dimension as the feature vector. Another way of looking at it is to forget about the hyperplane and just view it as a bunch of weights for each item in the feature vector. In this case, it needs one weighting for every item, then it multiplies each item by its weighting and outputs the result.

Resources