refine figure 1 using logarithmic and power transformationson is c, but in the power transformation the parameters to choose are c and γ. in matlab

To refine figure 1 using logarithmic and power transformations in Matlab, you can use the following code:

main.m
% Read the input image
I = imread('figure1.png');

% Apply the logarithmic transformation
I_log = log(double(I) + 1);
I_log = uint8((I_log ./ max(I_log(:))) .* 255);

% Apply the power transformation
c = 1; % constant
gamma = 0.5; % parameter to choose
I_pow = c .* double(I) .^ gamma;
I_pow = uint8((I_pow ./ max(I_pow(:))) .* 255);

% Display the original and transformed images
figure;
subplot(1,3,1), imshow(I), title('Original image');
subplot(1,3,2), imshow(I_log), title('Logarithmic transformation');
subplot(1,3,3), imshow(I_pow), title('Power transformation');
571 chars
19 lines

In the code above, we first read the input image using the imread function. We then apply the logarithmic transformation by first converting the image to double precision using the double function, adding 1 to avoid the logarithm of 0, taking the logarithm using the log function, scaling the result to the range [0, 255] using the uint8 function, and finally displaying the result using the imshow function.

Next, we apply the power transformation using the equation s = c * r^gamma, where s is the output pixel value, r is the input pixel value, c is a constant, and gamma is a parameter to choose. In this example, we set c = 1 and gamma = 0.5, but you can experiment with different values to achieve the desired transformation. Again, we scale the result to the range [0, 255] using the uint8 function and display the result using the imshow function.

Finally, we display all three images (original, logarithmic transformation, and power transformation) side by side using the subplot function and the title function to label each plot accordingly.

gistlibby LogSnag