Click here to Skip to main content
15,887,988 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to get the height of the tower inside the image. I measured it by the rule I found it 9 cm. I use contour to do the segmentation then I computed the height of contour but the output of my program is 358.
what is it? and how I get the real result?

What I have tried:

temp = new Image<Bgr, byte>("F:\\project\\brige1.png");

            Image<Gray, byte> img3 = temp.Convert<Gray, byte>().ThresholdBinary(new Gray(50), new Gray(255)).Dilate(1).Erode(1);

            Emgu.CV.Util.VectorOfVectorOfPoint contours = new Emgu.CV.Util.VectorOfVectorOfPoint();
            Mat m = new Mat();
            CvInvoke.FindContours(img3, contours, m, Emgu.CV.CvEnum.RetrType.External, Emgu.CV.CvEnum.ChainApproxMethod.ChainApproxSimple);
            Dictionary<int, double> dict = new Dictionary<int, double>();
            if (contours.Size > 0)
            {
                for (int i = 0; i < contours.Size; i++)
                {

                    Rectangle rect = CvInvoke.BoundingRectangle(contours[i]);
                    double aera = CvInvoke.ContourArea(contours[i]);

                    int h = rect.Height;

                    MessageBox.Show("The heith is = " + h.ToString());

                    CvInvoke.Rectangle(temp, rect, new MCvScalar(0, 255, 0), 3);


                    pictureBox5.Image = temp.Bitmap;

                    
                }
Posted
Updated 5-Nov-19 4:20am
Comments
Richard Deeming 1-Nov-19 14:47pm    
Was it exactly 9cm, or was it closer to 10cm?

I suspect the 358 is in pixels. If your display is 92dpi, that would be approximately 3.9 inches, or 9.9cm.
Member 14129828 1-Nov-19 15:21pm    
you are right ...thank you ...I have calculated the range of the image and got the close value of your hypothesis
Patrice T 1-Nov-19 15:25pm    
If problem is solved, post the solution and accept it.
Member 14129828 1-Nov-19 15:44pm    
yes ...the problem solved..but how I post it?

1 solution

As discussed in the comments, the value 358 is in pixels. On a 92dpi screen, that works out at approximately 3.9 inches, or 9.9cm.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900