how to compute min for image with black border?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
fred bnm
am 8 Jun. 2016
Kommentiert: Chad Greene
am 17 Jun. 2016
Hi, I have an image with black border in 2000 * 2000.after using min function the output is 0 or 1.that The minimum is related to border of the image that is black.how to compute min or max other than black border? my code is here.by this code output min is NaN.
img=imread('image.tif');
figure(1),imshow(img),title('original');
[M,N]=size(img);
for i=1:M
for j=1:N
if img(i,j)<1
img(i,j)=NaN;
end
end
end
minofimg=min(min(img));
0 Kommentare
Akzeptierte Antwort
Chad Greene
am 8 Jun. 2016
What about
min(img(img~=0))
That is, the minimum value of img values that are not zero.
6 Kommentare
Chad Greene
am 17 Jun. 2016
You can specify the range of rows and columns you want to keep. For example start with this image:
img = imread('cameraman.tif');
image(img)
colormap(gray)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/183784/image.png)
And clip the first 49 rows, and the last 47 rows. Also clip the first 124 columns:
keeprows = 50:209;
keepcols = 125:256;
img_trimmed = img(keeprows,keepcols);
image(img_trimmed)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/183786/image.png)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!