フィルターのクリア

Rescale 8-bit grayscale image

1 回表示 (過去 30 日間)
Ben Ma
Ben Ma 2021 年 9 月 8 日
編集済み: Ben Ma 2021 年 9 月 9 日
  1. intensity values in the range [0..63] in f become 0,
  2. in the range [63+1..126] are rescaled into the range [0..120],
How to rescale the image? Thanks.

回答 (1 件)

DGM
DGM 2021 年 9 月 8 日
編集済み: DGM 2021 年 9 月 9 日
Here's a start:
inpict = imread('cameraman.tif');
inrange = [64 126; 127 230];
outrange = [0 120; 151 255]; % you sure you don't mean 121?
m = inpict<=inrange(1,2);
outpict = zeros(size(inpict),'uint8');
outpict(m) = (double(inpict(m))-inrange(1,1))./(inrange(1,2)-inrange(1,1)) ...
.*(outrange(1,2)-outrange(1,1))+outrange(1,1);
outpict(~m) = (double(inpict(~m))-inrange(2,1))./(inrange(2,2)-inrange(2,1)) ...
.*(outrange(2,2)-outrange(2,1))+outrange(2,1);
imshow(outpict)
imhist(outpict)
You can do the same using interpolation:
inpict = imread('cameraman.tif');
inrange = [0 64 126 127 230 255];
outrange = [0 0 120 151 255 255];
outpict = uint8(interp1(inrange,outrange,double(inpict),'linear','extrap'));
imshow(outpict)
imhist(outpict)
  2 件のコメント
Ben Ma
Ben Ma 2021 年 9 月 8 日
No, not 121, will skip that middle range
Ben Ma
Ben Ma 2021 年 9 月 8 日
Thanks a lot.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by