Polynomial line fitting to dense data

Antworten (2)

Image Analyst
Image Analyst am 15 Mär. 2020
Bearbeitet: Image Analyst am 15 Mär. 2020

0 Stimmen

Yes, just try it. Attached is a demo. Attach your data if you have trouble.
John D'Errico
John D'Errico am 15 Mär. 2020

0 Stimmen

Of course it is.
help polyfit
Do NOT fit anything of higher order than a straight line to that crap though. You will be kidding yourself if you do.

13 Kommentare

Kyuhee Jo
Kyuhee Jo am 15 Mär. 2020
Well it’s a plot from binomial matrix converted from a color histogram plot image (rgb). So technically, I have to find a line that best represents the shape of the bright region which should probably be a curved line. Is there any other way I could do the task though?
Kyuhee Jo
Kyuhee Jo am 15 Mär. 2020
Kyuhee Jo
Kyuhee Jo am 15 Mär. 2020
The image looke like this and what I want to do is something like this:
Kyuhee Jo
Kyuhee Jo am 15 Mär. 2020
(This one is a line I derived by cubic regression. Probably not the best way to do this task)
Kyuhee Jo
Kyuhee Jo am 15 Mär. 2020
(Linear regression)
Image Analyst
Image Analyst am 15 Mär. 2020
Bearbeitet: Image Analyst am 15 Mär. 2020
What are you trying to do? What do the two axes represent? Exactly what is "binomial matrix converted from a color histogram"? A color histogram (histogram of the 3 color channels) would be either 1-D histograms of each color channel of an RGB image one channel at a time, or a 3-D array of counts. You have neither, so exactly what is that?
Anyway is the "bright region" the yellow part of the image? So the shape of it would have to be a 2-D outline/perimeter/boundary of that yellow region, not a line through it, right?
John D'Errico
John D'Errico am 15 Mär. 2020
As i said, if you are fitting that data using a cubic polynomial, you are lying to yourself. There is no way you can rationally justify that high order of a fit.
Instead, I would probably recommend that you not even use a tool like polyfit, because this looks like a total least squares problem (often called errors in variables). Even polyfit will give you an estimate for the slope that is probably biased towards zero here.
Without your data, I cannot show you the difference between polyfit and a total least squares estimate on that data, however it would not be insignificant.
Kyuhee Jo
Kyuhee Jo am 15 Mär. 2020
Bearbeitet: Kyuhee Jo am 15 Mär. 2020
The original image is a color histogram that represents intensity of each pixel based on a 2 dimensional colormap converted from traditional RGB (using two angles between R, G, and B). The bright region shows high intensity. And no, I don’t need perimeter/ outline but a lune that fits the trend (?), general shape of the yellow part (so something along the line of the past 2 images that I’ve posted). And I was also trying to use the linear regression code in this link: https://www.mathworks.com/matlabcentral/fileexchange/64930-linear-regression-simplest-implementation Is this the code for total least square?
Image Analyst
Image Analyst am 15 Mär. 2020
Bearbeitet: Image Analyst am 15 Mär. 2020
Again, what do the two axes represent? What two angles? If you plot a point (R, G, B) in a 3-D space, there are not (just) two angles. OK, let's say you were going to use xlabel() and ylabel() to label the axes of your histogram. What would you put?
xlabel('Fill in the label here');
ylabel('Fill in the label here');
If you read our profiles, you can see that John and I both have multi-decade experience in color science and color imaging so don't feel like you have to hold back on the details. We have very extensive knowledge in the subject.
Kyuhee Jo
Kyuhee Jo am 15 Mär. 2020
So this figure is the raw data I am dealing with. The image on the right is colormap created by interpreting R,G,B into 2 angles theta1 and theta 2 that represents the angle between vector R, G, B in 3D space. The X-axis and y-axis should be theta 1 and theta 2.
Then, the image on the right map the color intensity of original image as per the color map, i.e. 1-on-1 intensity of each color at each point on the left. So the x label should also be theta 1 and y label theta 2.
The goal of this image processing is to separate different colors (say, color A, B, and C) and create component images that only captures one color each. We want to achieve this without any prior knowledge of what color A, B, and C are (because it may slightly differ across different images), i.e. we want to use relative color information instead. In order to do so, I need to draw a nonlinear line that approximates the trend of yellow/green/skyblue region.
Image Analyst
Image Analyst am 15 Mär. 2020
I still don't know what you want. An (R, G, B) point will have three angles from the axes. Anyway, from your description of what you want to do I don't think you want to do what you asked. I think you want to do either PCA or LDA on the image. I'm attaching demos for both.
Kyuhee Jo
Kyuhee Jo am 15 Mär. 2020
For clarification, we are using angles between the three vectors, theta 1 btw R & G and theta 2 btw G&B
Image Analyst
Image Analyst am 16 Mär. 2020
Did you try the LDA or PCA classification?

Melden Sie sich an, um zu kommentieren.

Gefragt:

am 15 Mär. 2020

Kommentiert:

am 16 Mär. 2020

Community Treasure Hunt

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

Start Hunting!

Translated by