Asked by Stelios Fanourakis
on 24 Feb 2019

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

Answer by Image Analyst
on 24 Feb 2019

See attached spatial calibration demo. Adapt as needed.

Stelios Fanourakis
on 24 Feb 2019

@Image Analyst.

I used this line that I must have modified by another previous code of yours

for col = 390 : 466

heights(col) = rgbImage(370,col) - rgbImage(215,col);

end

And the exported values in my excel are

6

6

6

7

9

11

13

15

12

11

9

7

7

12

17

21

26

27

26

25

25

24

28

33

37

41

43

36

28

19

11

10

15

20

27

32

33

32

32

31

31

43

53

62

75

81

81

80

79

78

74

69

63

58

52

52

53

54

55

53

47

40

31

25

19

16

13

9

6

8

12

16

20

24

21

17

14

Where I should actually get only 155 for all columns. Why the code line I used is not working properly? What is the wrong with it???

Stelios Fanourakis
on 24 Feb 2019

I guess this line

heights(col) = rgbImage(370,col) - rgbImage(215,col);

Does not make any arithmetic calculation. It is different than imdistline()

imdistline subtracts arithmetic number of pixels from point A to point B.

But by indexing the rows and columns of an image and making subtraction out of those, is totally different thing. Isn't it?

If not arithmetic subtraction then what?

Stelios Fanourakis
on 24 Feb 2019

I see. It is a subtraction of pixels values (intensity values), not the pixel as a number.

I double checked it.

Thanks for your time Image Analyst.

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 11 Comments

## Stelios Fanourakis (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/446660-why-this-incongruency-happens-regarding-number-of-pixels#comment_674545

## Stelios Fanourakis (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/446660-why-this-incongruency-happens-regarding-number-of-pixels#comment_674551

## Rik (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/446660-why-this-incongruency-happens-regarding-number-of-pixels#comment_674552

## Stelios Fanourakis (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/446660-why-this-incongruency-happens-regarding-number-of-pixels#comment_674559

## Rik (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/446660-why-this-incongruency-happens-regarding-number-of-pixels#comment_674560

## Stelios Fanourakis (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/446660-why-this-incongruency-happens-regarding-number-of-pixels#comment_674565

## Stelios Fanourakis (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/446660-why-this-incongruency-happens-regarding-number-of-pixels#comment_674577

## Rik (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/446660-why-this-incongruency-happens-regarding-number-of-pixels#comment_674581

## Stelios Fanourakis (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/446660-why-this-incongruency-happens-regarding-number-of-pixels#comment_674584

## Image Analyst (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/446660-why-this-incongruency-happens-regarding-number-of-pixels#comment_674589

## Stelios Fanourakis (view profile)

Direct link to this comment:https://www.mathworks.com/matlabcentral/answers/446660-why-this-incongruency-happens-regarding-number-of-pixels#comment_674597

Sign in to comment.