how can i calculate the value of Sigmoid Function for image in matlab ?

2 visualizaciones (últimos 30 días)
Maryem Munm
Maryem Munm el 26 de Nov. de 2015
Respondida: Samayochita el 12 de Feb. de 2025

Respuestas (1)

Samayochita
Samayochita el 12 de Feb. de 2025
Hi Maryem,
To apply the Sigmoid function to an image:
  • Read the image
  • Convert the image to grayscale
  • Convert the image to double precision (since pixel values are usually in uint8 format)
  • Apply the sigmoid function
  • Normalize the output (Optional: to bring values back to displayable range)
Here is an example code that I wrote:
% Parameters for the Sigmoid function
alpha = 100; % Location parameter (adjust as needed)
beta = 50; % Scale parameter (adjust as needed)
% Apply the Sigmoid function
sigmoid_img = 1 ./ (1 + exp(-(img_double - alpha) / beta));
% Scale back to 0-255 for display
sigmoid_img = uint8(sigmoid_img * 255);
% Display results
figure;
subplot(1,2,1), imshow(img), title('Original Image');
subplot(1,2,2), imshow(sigmoid_img), title('Sigmoid Transformed Image');
Hope this helps!

Categorías

Más información sobre Convert Image Type en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by