在matlab中获得图像的前25%强度值

Ras*_*hid 1 matlab image-processing

我想创建一个阈值掩码,等于图像强度值的前25%.我使用了这段代码,但没有生成所需的值:

img1 = im2double(imread('image1.tif'));
threshold = (0.25);
img1(img1 < threshold) = 0;
img1(img1 > threshold) =1;
Run Code Online (Sandbox Code Playgroud)

mat*_*urg 5

尝试 prctile

img1 = im2double(imread('image1.tif'));
threshold = prctile(img1(:),75);
img1(img1 <  threshold) = 0;
img1(img1 >= threshold) = 1;
Run Code Online (Sandbox Code Playgroud)