@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..!!
Sie verfolgen jetzt diese Frage
- Aktualisierungen können Sie in Ihrem Feed verfolgter Inhalte sehen.
- Je nach Ihren Kommunikationseinstellungen können Sie auch E-Mails erhalten.
How to calculate Picture length from picture?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
How to calculate Picture length from picture?
20 Kommentare
Devyani Sankhe
am 29 Jan. 2021
⋮
-
Verknüpfen
Direkter Link zu diesem Kommentar
Bearbeitet: Devyani Sankhe
am 29 Jan. 2021
Walter Roberson
am 29 Jan. 2021
⋮
-
Verknüpfen
Direkter Link zu diesem Kommentar
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;
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
Devyani Sankhe
am 29 Jan. 2021
⋮
-
Verknüpfen
Direkter Link zu diesem Kommentar
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
am 29 Jan. 2021
⋮
-
Verknüpfen
Direkter Link zu diesem Kommentar
Devyani Sankhe
am 29 Jan. 2021
⋮
-
Verknüpfen
Direkter Link zu diesem Kommentar
Bearbeitet: Devyani Sankhe
am 29 Jan. 2021
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
am 29 Jan. 2021
⋮
-
Verknüpfen
Direkter Link zu diesem Kommentar
Image Analyst said "I've also attached a demo for you." and the Answer has spatial_calibration_demo.m attached.
Devyani Sankhe
am 29 Jan. 2021
⋮
-
Verknüpfen
Direkter Link zu diesem Kommentar
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
am 29 Jan. 2021
⋮
-
Verknüpfen
Direkter Link zu diesem Kommentar
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
am 8 Feb. 2021
⋮
-
Verknüpfen
Direkter Link zu diesem Kommentar
Bearbeitet: Esila Darci
am 8 Feb. 2021
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
Walter Roberson
am 8 Feb. 2021
⋮
-
Verknüpfen
Direkter Link zu diesem Kommentar
high = 173
mean(high)
std(high)
Esila Darci
am 8 Feb. 2021
⋮
-
Verknüpfen
Direkter Link zu diesem Kommentar
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
am 8 Feb. 2021
⋮
-
Verknüpfen
Direkter Link zu diesem Kommentar
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
am 8 Feb. 2021
⋮
-
Verknüpfen
Direkter Link zu diesem Kommentar
Bearbeitet: Esila Darci
am 8 Feb. 2021
@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
am 8 Feb. 2021
⋮
-
Verknüpfen
Direkter Link zu diesem Kommentar
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
am 9 Feb. 2021
⋮
-
Verknüpfen
Direkter Link zu diesem Kommentar
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
am 9 Feb. 2021
⋮
-
Verknüpfen
Direkter Link zu diesem Kommentar
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
am 9 Feb. 2021
⋮
-
Verknüpfen
Direkter Link zu diesem Kommentar
@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
Walter Roberson
am 9 Feb. 2021
⋮
-
Verknüpfen
Direkter Link zu diesem Kommentar
You should do the MATLAB Onramp at least as far as arrays and indexing.
Esila Darci
am 9 Feb. 2021
⋮
-
Verknüpfen
Direkter Link zu diesem Kommentar
Bearbeitet: Esila Darci
am 9 Feb. 2021
I attended the onramp course now completaly but still don't know how to recall measured h1, h2, h3 and h4 value
Walter Roberson
am 9 Feb. 2021
⋮
-
Verknüpfen
Direkter Link zu diesem Kommentar
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);
Akzeptierte Antwort
Image Analyst
am 9 Feb. 2021
Run my attached spatial calibration demo and then you will understand what to do.
9 Kommentare
Walter Roberson
am 9 Feb. 2021
⋮
-
Verknüpfen
Direkter Link zu diesem Kommentar
They have that; you posted it above. They want someone to adapt it for their purposes (which are not well-defined.)
Esila Darci
am 9 Feb. 2021
⋮
-
Verknüpfen
Direkter Link zu diesem Kommentar
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
am 9 Feb. 2021
⋮
-
Verknüpfen
Direkter Link zu diesem Kommentar
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
am 9 Feb. 2021
⋮
-
Verknüpfen
Direkter Link zu diesem Kommentar
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.
Esila Darci
am 10 Feb. 2021
⋮
-
Verknüpfen
Direkter Link zu diesem Kommentar
Walter Roberson
am 10 Feb. 2021
⋮
-
Verknüpfen
Direkter Link zu diesem Kommentar
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
am 10 Feb. 2021
⋮
-
Verknüpfen
Direkter Link zu diesem Kommentar
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
am 2 Apr. 2021
⋮
-
Verknüpfen
Direkter Link zu diesem Kommentar
@Devyani Sankhe, not sure what your edit was, but did my Answer solve your problem?
Devyani Sankhe
am 2 Apr. 2021
⋮
-
Verknüpfen
Direkter Link zu diesem Kommentar
solved, thanks
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Es ist ein Fehler aufgetreten
Da Änderungen an der Seite vorgenommen wurden, kann diese Aktion nicht abgeschlossen werden. Laden Sie die Seite neu, um sie im aktualisierten Zustand anzuzeigen.
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.
Amerika
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- 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)
Asien-Pazifik
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)