Linear regression-line based on 2D image

5 vues (au cours des 30 derniers jours)
Jesper Bjerregaard
Jesper Bjerregaard le 6 Déc 2018
Hi there,
I'm currently trying to determine the edge of an image of a sample I'm working with. The image on the left is the actual sample (heavily cropped). I made a contourf plot to better be able to see the actual edge I need to create the regression line for (yellow edge on image to the right).
Does MATLAB have a feature that can do this? I have been messing around with gradient and edge, but without luck.
test1.jpg
A little info on the original image (the axis are in pxl btw):
I import the image from a .jpg file using the imread function. I then split up the image in to two coordinate matrices (X, Y) and three matrices containing the R G B information. Something like this:
[X,map] = imread(fullfile(filepath, strcat(name, ext)));
X = ind2rgb(X,map);
dim = size(X);
y = linspace(0,dim(1)-1,dim(1));
x = linspace(0,dim(2)-1,dim(2));
[img.X,img.Y] = meshgrid(x,y);
img.R = I(:,:,1);
img.G = I(:,:,2);
img.B = I(:,:,3);
To do the contourf plot I have to make some small changes, they look like this:
R = double(img.R);
G = double(img.G);
B = double(img.B);
z = (R.*G.*B).^(1/3); % Not really sure if this is the best way to represent RGB by single number, but it gives an acceptable contourf plot
contourf(img.X,img.Y,z,2)
So I basically have a matrix (z) which contains all the information I need. I'm just not sure how to handle it.
Any advice is welcome.
Thanks in advance.
Best regards,
Jesper
  4 commentaires
Jesper Bjerregaard
Jesper Bjerregaard le 6 Déc 2018
Okay. So the original Image is actually a .jpg. The microscopesoftware used to take the image always saves in high resolution jpg accompanied by a meta xml file. Anyway, the samples will never be quite the same. I'm trying to determine how colse the two edges (left and right) are to being parrallel, while also determining the curvature of the top of the sample (yellow layer on original image - then one I just uploaded), by fitting the periferi of a circle to match the layer and then determine the radius of that circle.
And since the images are taken with a microscope, the location of the samples are never going to be the same. They have to be analysed individually. Anyway, I'll look into what you suggested and return if I reach a solution (or if I recieve more suggestions J).
Jesper Bjerregaard
Jesper Bjerregaard le 6 Déc 2018
And yes, the stuff at the top has to be ignored. It should be clear to see the edge I'm talking about on the high res image (the edge starts at the bottom, being a lighter gray than the rest).
I'm sorry for not keeping this reply in a single comment, but my computer is having a very hard time after I uploaded the image on this page.

Connectez-vous pour commenter.

Réponses (0)

Produits


Version

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by