@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?
조회 수: 1 (최근 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개)
참고 항목
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 (한국어)