Why this incongruency happens regarding number of pixels?
Info
This question is closed. Reopen it to edit or answer.
Show older comments
Hi
I use the image I attached.
I use this line to get the sum of pixels from row 307 to 366, at columns from 464 to 490
for col = 464 : 490
heights(col) = sum(rgbImage(366,col) - rgbImage(307,col));
end
This subtraction would give us 59 pixels and with a calibration factor of 0,042 it would give us around 2,48 mm for all the columns.
When I export the values to an excel file I get
If you multiply the below values with 0,042 you only get around 6 values acceptable and the closest to 2,5mm.
Why this incongruency???
By measuring heights(col), I should get 59 pixels multiplied by 0,042 I would get around 2,47 mm. Why I don't get those values when I export them to Excel??
Any ideas?
1
5
7
10
13
21
31
38
48
54
58
65
69
76
75
73
69
67
66
58
52
45
39
33
28
24
18
14
11 Comments
Stelios Fanourakis
on 24 Feb 2019
Stelios Fanourakis
on 24 Feb 2019
Rik
on 24 Feb 2019
"Is my question so difficult to get answered?"
You do realize this only discourages people from investing time and energy in your question?
As for your actual question: it is not really clear to me what is failing. Is everything inside Matlab going as it should but an export to Excel fails? Then what code are you using to do this export?
Also, it looks like the first 463 values would be 0. Did you check if the values start at row 464 in Excel?
Stelios Fanourakis
on 24 Feb 2019
Rik
on 24 Feb 2019
The imdistline function returns an object. You will have to use one of the object functions for imdistline objects to retrieve the data you need.
Stelios Fanourakis
on 24 Feb 2019
Stelios Fanourakis
on 24 Feb 2019
Rik
on 24 Feb 2019
I suspect you want something like this:
for col = 464 : 491
h = imdistline(gca,[col col],[307 366]);
dist(col) = getDistance(h)
end
Stelios Fanourakis
on 24 Feb 2019
Edited: Stelios Fanourakis
on 24 Feb 2019
Image Analyst
on 24 Feb 2019
If you have an RGB image, why are you conly giving two indexes? It should have 3.
Perhaps you'd find improfile easier since it just returns x,y coordinates and you can find the end points easily from the first element and the last element of the coordinates.
Why are you summing the values?
Stelios Fanourakis
on 24 Feb 2019
Answers (1)
Image Analyst
on 24 Feb 2019
0 votes
See attached spatial calibration demo. Adapt as needed.
5 Comments
Stelios Fanourakis
on 24 Feb 2019
Image Analyst
on 24 Feb 2019
It's just taking 1000 samples along the line. It looks like you don't need the RGB values so you can ignore them and just look at cx and cy.
distanceInPixels = sqrt((cx(1)-cx(end)).^2 + (cy(1)-cy(end)).^2)
Stelios Fanourakis
on 24 Feb 2019
Stelios Fanourakis
on 24 Feb 2019
Stelios Fanourakis
on 24 Feb 2019
This question is closed.
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!