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

3 views (last 30 days)

Answers (1)

Samayochita
Samayochita on 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!

Categories

Find more on Convert Image Type in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!