I'm trying to do measurements based on image processing : first I do some image processing to find detect the pixels that changed between the background and my image, and then I perform a linear regression to find the number of objects from the number of changing pixels.
The issue is that I have rather few samples (24 for now) because it is very time-consuming to get them.
I'm trying to find the optimal parameters (3 for the image processing + 2 for the regression) and to estimate the variance of the residuals. For finding the optimal parameters, I do a grid search on the 3 image processing parameters, and for each I compute the regression (and estimate the variance of residuals).
The problem is that I'm not sure how best to estimate this variance : - If I were to measure a fixed value + noise, I know that I take the sum of the squares of the residuals, and I divide by the number of samples minus 1 - If I make a linear regression, from what I understand I have to divide by the number of samples minus 2. - But I'm not sure about my situation : should I divide by N-2 or by N-5? (ie do the parameters of the grid search count as lost degrees of freedom the same way as the parameters of the regression?)
Thank you very much in advance Felix
PS : just to make sure, is it at all correct to try to estimate the variance this way or should I go for separated learning/testing sets and/or to cross validation?