@Image Analyst can you please respond to this? I will be very thankful to you, if you answer it. Thanks in advance...!! I am new at matlab..!!
How to calculate Picture length from picture?
6 次查看(过去 30 天)
显示 更早的评论
How to calculate Picture length from picture? ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/500268/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/500268/image.png)
20 个评论
Walter Roberson
2021-1-29
By measuring the length of the heavy lower bar in pixels, you can find the number of pixels horizontal that correspond to 0.5
. Multiply by 2 to get the number of pixels per 1
; call that Rx;
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/503463/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/503468/image.png)
If you can assume that the vertical resolution is the same, then measure the length of the vertical arrow line. Divide by the Rx calculated above to get the length of the line in ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/503473/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/503473/image.png)
Devyani Sankhe
2021-1-29
Hi Walter,
Thank you so much, I 'm very new user at Matlab, can you please tell me a matlab code that please. Thanks a lot for your help. @Walter Roberson
Walter Roberson
2021-1-29
Devyani Sankhe
2021-1-29
编辑:Devyani Sankhe
2021-1-29
Dear Walter,
Thanks a lot, but here is not any code mentioned? can you please tell me an code? please Thanks in advance .!!@Walter Roberson
Walter Roberson
2021-1-29
Image Analyst said "I've also attached a demo for you." and the Answer has spatial_calibration_demo.m attached.
Devyani Sankhe
2021-1-29
Hi Walter,
Thanks, i have gone through the link you have provided, but there is no clear instruction. I hope yo will help me by providing an code to perform my task. I am still learning basic matlab, so I would be thankful to you if you do provide me an code.
Walter Roberson
2021-1-29
Run the program. It will lead you step by step. (I do not recommend running it on MATLAB Online; it works, but you have to know where to click to see the prompts.)
When the menu of images comes up, select the 6th option "My own" and go through selecting your image.
Esila Darci
2021-2-8
编辑:Esila Darci
2021-2-8
Thanks i followed your discussion and code and calculated the height of my every rectangle. But, i have to calculate following thing
1) mean of height
2) standard deaviation in that height
can you please tell me an code for that? so i can run that code to find out in my PC
Image attached in the comment
Thanks a lot in advance.
Esila
Esila Darci
2021-2-8
Thank you @Walter Roberson but i didn't understand how we can automatically recall the h1, h2, h3 and h4 in the matlab code ? can you please tell me that.
Walter Roberson
2021-2-8
bwareafilt() to get rid of the text and arrow at the left. regionprops() to get bounding boxes of the four rectangles. You might need to do further filtering to eliminate more drawings, such as removing the objects with high solidity.
The heights in pixels would then be read out from the regionprops BoundingBox -- in particular, the 4th column of output of each BoundingBox .
After that you would have the task of finding the reference scale to the left and measuring its height in pixels, and then scaling the heights you got from the bounding boxes.
Esila Darci
2021-2-8
编辑:Esila Darci
2021-2-8
@Walter Roberson thank a million but i don't understand can you write a code in this file so i will run
Here is the code link https://www.mathworks.com/matlabcentral/answers/uploaded_files/14768/spatial_calibration_demo.m
Just for your information i have already calculated the h1, h2, h3, and h4 but don't know the how to calculate mean and standard deviation. ( I don't want to put h1, h2, h3, and h4 manually)
thank you in advance
Walter Roberson
2021-2-8
You should be reading the source code for that demo and extracting the ideas and then writing your own code.
It is quite simple at heart: have the user point to two locations. Measure the pixel distance between the locations. Ask the user how much real-world distance it is. Then loop having the user point to two places, measure the pixel distance, scale by the appropriate scale factor calculated earlier, and report to the user.
If you had that kind of framework, then it would be easy for you to store the measured distances in an h array that you later used mean() and std() on.
Esila Darci
2021-2-9
Thanks a lot for explanation, I am not using Matlab frequently. Can you please write me an code for that. I will be very much thankful for that. I tried multiple times but not succeeded. Thank you
Walter Roberson
2021-2-9
No, I do not wish to write this code for you. The way for you to get better at MATLAB is for you to read existing MATLAB code and program in it yourself.
I have numerous programs I am supposed to be working on, and I have a whole bunch of systems administration work to do. My writing this code for you so that you do not have to learn more about MATLAB is not realistically going to happen.
Esila Darci
2021-2-9
@Walter Roberson atleast explain the few steps or suggest some other demo where i can learn by myself. To just auto store the h1, h2, h3 and h4 in the matlab code, when the user will measure the data. After that i will calculate the mean and standard deviation as i derived the code for that but only one issue i am facing is that i am putting the h1, h2, h3 and h4 value manually. Small request to you. Thank you so much.
Br
Esila
Esila Darci
2021-2-9
编辑:Esila Darci
2021-2-9
I attended the onramp course now completaly but still don't know how to recall measured h1, h2, h3 and h4 value
Walter Roberson
2021-2-9
number_of_measurements = 4;
h = zeros(1, number_of_measurements);
for K = 1 : number_of_measurements
measure a distance, giving a result D
h(K) = D;
end
meanh = mean(h);
stdh = std(h);
采纳的回答
Image Analyst
2021-2-9
Run my attached spatial calibration demo and then you will understand what to do.
9 个评论
Walter Roberson
2021-2-9
They have that; you posted it above. They want someone to adapt it for their purposes (which are not well-defined.)
Esila Darci
2021-2-9
Yes i have calculated the h1, h2, h3 and h4 value but i don't know how to use it for mean and standard deviation calculation. (i don't want to put the h1, h2, h3 and h4 value manually).
Thanks
ESILA
Image Analyst
2021-2-9
To get the real world distances from h1, h2, etc. you do this:
h2InMm = h2InPixels * mmPerPixel;
mmPerPixel was calculated when you did the calibration. It's the pixel distance divided by the known real world distance. My demo walked you through how to get that.
Walter Roberson
2021-2-9
i don't want to put the h1, h2, h3 and h4 value manually
- When you adapt the code for your purpose, have it store the distances instead of just displaying them;
- Store the values into a vector, h(1), h(2), ... h(K) where K is how many you have stored so far.
Walter Roberson
2021-2-10
I already gave an outline at https://www.mathworks.com/matlabcentral/answers/727463-how-to-calculate-picture-length-from-picture-i-have-to-calculated-it-in-micron-can-you-guys-tell-m#comment_1318737 showing the code structure you would use to store h values into a vector at the time you find them, so that you do not need to "enter" them.
Image Analyst
2021-2-10
You said "Yes i have calculated the h1, h2, h3 and h4 value". So you have those already. Now you drew a distance along the horizontal scale bar in your image and told it that it was 0.5 microns. Let's say that the length of the scale bar was 300 pixels. So
micronsPerPixel = 0.5 / 300; % which equals 0.00166666666666667
So now you multiply the h values in pixels times the microns per pixel to get the answer in microns:
h2InMicrons = h2InPixels * micronsPerPixel;
So let's say h2InPixels was 900 pixels long. Then h2InMicrons would be 900 * 0.00166666666666667 which equals 1.5 microns.
Image Analyst
2021-4-2
@Devyani Sankhe, not sure what your edit was, but did my Answer solve your problem?
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing and Computer Vision 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)