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

5 ビュー (過去 30 日間)
Maryem Munm
Maryem Munm 2015 年 11 月 26 日
回答済み: Samayochita 2025 年 2 月 12 日

回答 (1 件)

Samayochita
Samayochita 2025 年 2 月 12 日
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!

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by