Continuous monochrome image sampling

1 view (last 30 days)
How can I sample a continuous monochrome image (f(x, y) = x(1 − y) + y(1 − x), 0 ≤ x ≤ 1, 0 ≤ y ≤ 1) to a discrete image with with 5 x 7 pixels by letting the lower left pixel be a sample from point (0,0) and the upper right from (1,1)?
How it could be quantify the discrete image with 32 different gray levels from 0 to 31??

Accepted Answer

Walter Roberson
Walter Roberson on 8 Sep 2022
xvec = linspace(0,1,7); %x is columns
yvec = linspace(0,1,5); %y is rows
[X, Y] = meshgrid(xvec, yvec);
F = X.*(1-Y) + Y.*(1-X);
imagesc(F); colormap(gray)
  4 Comments
Walter Roberson
Walter Roberson on 9 Sep 2022
For the case where what you care about is 32 gray levels
xvec = linspace(0,1,7); %x is columns
yvec = linspace(0,1,5); %y is rows
[X, Y] = meshgrid(xvec, yvec);
F = X.*(1-Y) + Y.*(1-X);
imagesc(F); colormap(gray(32))
For the case where you do care about the array being represented as 0 to 31
xvec = linspace(0,1,7); %x is columns
yvec = linspace(0,1,5); %y is rows
[X, Y] = meshgrid(xvec, yvec);
F = X.*(1-Y) + Y.*(1-X);
Fq = floor(rescale(F,0,32*(1-eps)));
imagesc(Fq); colormap(gray(32))

Sign in to comment.

More Answers (0)

Categories

Find more on Images in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!