Linear regression-line based on 2D image
Afficher commentaires plus anciens
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.

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
Image Analyst
le 6 Déc 2018
I don't think contourf() is the right approach. Can you upload the original image by itself. The good PNG or TIFF image, not the crummy JPG image with crummy jpg artifacts. Don't use jpg format for image analysis if you can at all help it. Also post a picture of what you consider to be the edge. Like, is that junk at the top noise to be ignored, or a legimate edge? Also, is the shape standard, so that you could correlate a standard template with it using normxcorr2(), or is the shape different from image to image?
Jesper Bjerregaard
le 6 Déc 2018
Jesper Bjerregaard
le 6 Déc 2018
Jesper Bjerregaard
le 6 Déc 2018
Réponses (0)
Catégories
En savoir plus sur Image Segmentation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
