How to find minimum and maximum pixel value in image

Hello Everyone, i hope you are doing well.
I have the following to images. i want detect the pattern and find the minimum and maximum value for the pattern
for example the first image sinewave. i want to detect the shape and find the value for upper peak and lower peak.
same for the second image
Can anybody help me in that

 Accepted Answer

>i want detect the pattern and find the minimum and maximum value for the pattern
The images have black background with value 0 and a white line with value 255.
You can use max(org:find) function to find non-zero value in each columns in the picture data.
image = imread('im_003002.png');
[~, wave] = max(image); % thx @Scott MacKenzie for x = 1:size(image,2) wave(x) = find(image(:,x)); end
max(wave) % It is y coordinate value of each dots on the white line.
ans = 991
min(wave) % It is y coordinate value of each dots on the white line.
ans = 981
plot(wave);

7 Comments

@Atsushi Ueno also for the second image too. How can i do that?
It is the same - just change the name of the file passed to imread():
image = imread('im_005001.png');
for x = 1:size(image,2)
wave(x) = find(image(:,x));
end
max(wave) % It is y coordinate value of each dots on the white line.
ans = 998
min(wave) % It is y coordinate value of each dots on the white line.
ans = 961
plot(wave);
@Atsushi Ueno, you don't need the for-loop. The same result is obtained with...
image = imread('im_003002.png');
[~, wave] = max(image);
max(wave) % It is y coordinate value of each dots on the white line.
min(wave) % It is y coordinate value of each dots on the white line.
plot(wave);
@Atsushi Ueno @Scott MacKenzie @_ I also want to detect the shape for both images using image processing thresholding or hough transform
How can i do that?
@_ Thank you. Yes, It's the same.
@Scott MacKenzie Thank you. That's what I would do.
@Med Future Is your expected output a formula of the function?
What exactly do you mean when you say "detect the shape"?
Do you want a mathematical expression of the periodic function?
Do you want to classify the type of periodic waveform?
Are you trying to find instances of the same (or similar) shape in other images?
If you want the first one, note that nothing in these images conveys any calibration information. All units will be in pixels. You will need to know the relationship between image coordinates and data coordinates.
@Atsushi Ueno@_ @Scott MacKenzie @DGM Thank for you answer. First step to find minimum and maximum of the value which is done using above code.
I also want to detect shape for example in periodic waveform im_003002.png the cycle repeat 6 times , i want to detect if any image comes how many cycles are there in the waveform

Sign in to comment.

More Answers (0)

Products

Release

R2021b

Community Treasure Hunt

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

Start Hunting!