Gray scale resolution matlab

2 visualizaciones (últimos 30 días)
akevg akevg
akevg akevg el 22 de Mzo. de 2022
Comentada: Tilkesh el 30 de En. de 2023
Hi, how can ı do this? ı need codes.

Respuesta aceptada

Image Analyst
Image Analyst el 23 de Mzo. de 2022
Editada: Image Analyst el 23 de Mzo. de 2022
That's done with discretize(). I'm sure there is example code in the help like there is for all functions.
  4 comentarios
Tilkesh
Tilkesh el 30 de En. de 2023
Thanks
Tilkesh
Tilkesh el 30 de En. de 2023
% One simpple example using above code.
% Define the x and y coordinate range
x = linspace(-5,5,100);
y = linspace(-5,5,100);
% Create a meshgrid of the x and y coordinates
[X,Y] = meshgrid(x,y);
% Define the grating period and duty cycle
period = 10;
duty_cycle = 0.5;
% Calculate the phase of the grating
phase = exp(i*2*pi*(X./period));
% grayImage = double(imread('cameraman.tif'));
grayImage =angle(phase);
n=1:1:8
% n=2.^nn
% n = [256, 32, 16, 8, 4, 2];
for k = 1 : length(n)
numLevels = n(k);
posterizedImage = discretize(grayImage, numLevels);
figure(1); subplot(3, 3, 1);
imagesc(angle(phase));colormap(gray);axis off;axis tight;axis square; title('Original');
subplot(3, 3, k+1);
imshow(posterizedImage, []);
caption = sprintf('%d gray levels', numLevels);
title(caption);
figure(2); subplot(3, 3, 1);
plot(angle(phase(50,:)));title('Original');
subplot(3, 3, k+1);
plot(posterizedImage(50,:))
caption = sprintf('%d gray levels', numLevels);
title(caption);
end

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Just for fun en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by