how can i use imdistline to calculate the pixel in the image?

any one has example about the imdistline? i need the example to view and will apply in my project.

Antworten (1)

Razvan
Razvan am 2 Feb. 2012
Here is an example:
% load an image
load flujet
imagesc(X);
% set up the measuring tool
h = imdistline(gca);
api = iptgetapi(h);
api.setLabelVisible(false);
% pause -- you can move the edges of the segment and then press a key to continue
pause();
% get the distance
dist = api.getDistance();
% print the result
fprintf('The length of the segment is: %0.2f pixels \n', dist)

8 Kommentare

what do you mean gca?
gca is a function call that means "get current axis".
i got this error...
??? Attempt to execute SCRIPT imdistline as a function:
C:\Users\WISH\Documents\MATLAB\imdistline.m
Error in ==> imdistline at 6
h = imdistline(gca);
how can i solve this?
when i run the coding it make error for that coding.how can i solve it?
You created your own imdistline.m file. Rename your file: the current name is conflicting with calling the MathWorks supplied imdistline() routine.
??? Attempt to execute SCRIPT imdistline as a function:
C:\Users\WISH\Documents\MATLAB\imdistline.m
Error in ==> contoh2 at 6
h = imdistline(gca);
i got this error...
I never knew there was a built-in imdistline - I've always used improfile(). But anyway, in your own personal overridden version of imdistline - you know the one where for some reason you did not take Walter's advice to rename it - you're missing "function imdistline(handleToFigure)" as the first line of your m-file. Of course you know that must replace the word "handleToFigure" with whatever handle name you're using to refer to the figures with.
when I replace the load function with imread function, the image become rectangle and not in actual size. How to make it show in actual size?

Melden Sie sich an, um zu kommentieren.

Tags

Gefragt:

am 2 Feb. 2012

Kommentiert:

am 18 Aug. 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by