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

4 visualizzazioni (ultimi 30 giorni)

Risposte (1)

Samayochita
Samayochita il 12 Feb 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!

Categorie

Scopri di più su Convert Image Type in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by