I want to ask about adaptive thresholding in my application

1 回表示 (過去 30 日間)
rama 2022 年 12 月 17 日
編集済み: DGM 2022 年 12 月 17 日
I want to do the threshold in a slider and i don't know how, can anyone help me please


DGM 2022 年 12 月 17 日
編集済み: DGM 2022 年 12 月 17 日
I have no idea what the goal is here, but I'm going to guess that it's also not generally correctly scaled. Is there any reason to believe that the source image is always 256x256? If not, then it won't work.
x=ones(256,1)*[1:256]; % this is always 256x256
% (1-double(input)) implies that input is already class 'double'
% so it's either incorrect inversion or redundant casting
Unless you intend to normalize the image, you shouldn't result to normalization for the simple purpose of class conversion. Maintain the proper scaling and scale the images accordingly when converting instead of blindly discarding information by normalizing.
Also, it's uint8(), not unit8()
Here's my guess
% get image
a = imread('peppers.png');
inpict = im2gray(a);
% convert once instead of multiple times
% keep image scaled correctly for its class
inpict = im2double(inpict);
% generate gradient that's correctly scaled for its class
sz = size(inpict);
xgrad = repmat(linspace(0,0.5,sz(2)),[sz(1) 1]);
% composite gradients using the image as a mask
offset = 50/255;
c2 = inpict.*(xgrad+offset) + (1-inpict).*xgrad;
% cast and rescale to uint8
% contrast is preserved because the image isn't blindly normalized
c3 = im2uint8(c2);
% display it

その他の回答 (0 件)


Help Center および File ExchangeImages についてさらに検索




Community Treasure Hunt

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

Start Hunting!

Translated by