@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..!!
Ahora está siguiendo esta pregunta
- Verá actualizaciones en las notificaciones de contenido en seguimiento.
- Podrá recibir correos electrónicos, en función de las preferencias de comunicación que haya establecido.
How to calculate Picture length from picture?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
How to calculate Picture length from picture?
20 comentarios
Devyani Sankhe
el 29 de En. de 2021
Editada: Devyani Sankhe
el 29 de En. de 2021
Walter Roberson
el 29 de En. de 2021
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
el 29 de En. de 2021
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
el 29 de En. de 2021
Devyani Sankhe
el 29 de En. de 2021
Editada: Devyani Sankhe
el 29 de En. de 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
el 29 de En. de 2021
Image Analyst said "I've also attached a demo for you." and the Answer has spatial_calibration_demo.m attached.
Devyani Sankhe
el 29 de En. de 2021
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
el 29 de En. de 2021
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
el 8 de Feb. de 2021
Editada: Esila Darci
el 8 de Feb. de 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
el 8 de Feb. de 2021
high = 173
mean(high)
std(high)
Esila Darci
el 8 de Feb. de 2021
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
el 8 de Feb. de 2021
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
el 8 de Feb. de 2021
Editada: Esila Darci
el 8 de Feb. de 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
el 8 de Feb. de 2021
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
el 9 de Feb. de 2021
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
el 9 de Feb. de 2021
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
el 9 de Feb. de 2021
@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
el 9 de Feb. de 2021
You should do the MATLAB Onramp at least as far as arrays and indexing.
Esila Darci
el 9 de Feb. de 2021
Editada: Esila Darci
el 9 de Feb. de 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
el 9 de Feb. de 2021
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);
Respuesta aceptada
Image Analyst
el 9 de Feb. de 2021
Run my attached spatial calibration demo and then you will understand what to do.
9 comentarios
Walter Roberson
el 9 de Feb. de 2021
They have that; you posted it above. They want someone to adapt it for their purposes (which are not well-defined.)
Esila Darci
el 9 de Feb. de 2021
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
el 9 de Feb. de 2021
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
el 9 de Feb. de 2021
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
el 10 de Feb. de 2021
Walter Roberson
el 10 de Feb. de 2021
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
el 10 de Feb. de 2021
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
el 2 de Abr. de 2021
@Devyani Sankhe, not sure what your edit was, but did my Answer solve your problem?
Devyani Sankhe
el 2 de Abr. de 2021
solved, thanks
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Se ha producido un error
No se puede completar la acción debido a los cambios realizados en la página. Vuelva a cargar la página para ver el estado actualizado.
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.
América
- 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)
Asia-Pacífico
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)