Enhance the image with non-linear function

3 次查看(过去 30 天)
Hello everyone, I'm a beginner in using Matlab and I want to know if what I did in solving this question right or wrong:
the question says:
Implement and test a method with the following specification. Input: A gray scale image Processing: Enhance the image with non-linear function Output: Enhanced image In the implementation follow the steps given below:
  • Read the image Im
  • The image will be in uint8 format. Convert it into double and transform the range of gray scale into [-1 1]. Call it TIm
  • Compute the max of the absolute values of the transformed image Tim i.e. max{|Tim|}.
  • Define a threshold as T = t x mean{|Tim|}, where t is user-defined and must be in the range (0,1). Try different values of t.
*Enhance the image using the following function:
where k > 1 is also user-defined. Try different values of k. Test different values of t and k to find the values which give the best enhancement results. Preparer a report showing the results with different values of t and k, and also write the comments on the behavior of these parameters for enhancement. __________
I solved the first four points as follows:
% Close images and clear the workspace, if there are any active contents
clc; clear all; close all;
% Read the image Im
Im = imread('noise_field.jpg');
%Convert it into double and transform the range of gray scale into [-1 1]
Imt = double(Im);
Tim = mat2gray(Imt, [-1, 1]);
%Compute the max of the absolute values of the transformed image Tim
MaxTim = max(abs(Tim));
%Define a threshold as T = t x mean{|Tim|}
t=double(0.1);
T= t*mean(Tim);
The last point I really have no idea about how to do it:(
Is my code correct?! I appreciate your help

采纳的回答

Image Analyst
Image Analyst 2016-3-7
No. max() gives the max column-by-column so you need to transform it into a column vector:
% Compute the max of the absolute values of the transformed image Tim
MaxTim = max(abs(Tim(:)));
%Define a threshold as T = t x mean{|Tim|}
t = 0.1;
T = t*mean(Tim(:));
% Compute binary map of different intensity ranges
darkPixels = Tim < -T;
mediumPixels = abs(Tim) < T;
brightPixels = Tim > T;
% Now create a new image
enhancedTim = zeros(size(Tim));
% Assign dark pixels
enhancedTim(darkPixels) = Tim + (k-1)*T;
% Do the same for medium and bright pixels with their formulas.
To get t and k, adapt this:
% Ask user for two floating point numbers.
defaultValue = {'45.67', '78.91'};
titleBar = 'Enter a value';
userPrompt = {'Enter floating point number 1 : ', 'Enter floating point number 2: '};
caUserInput = inputdlg(userPrompt, titleBar, 1, defaultValue);
if isempty(caUserInput),return,end; % Bail out if they clicked Cancel.
% Convert to floating point from string.
usersValue1 = str2double(caUserInput{1})
usersValue2 = str2double(caUserInput{2})
% Check for a valid number.
if isnan(usersValue1)
% They didn't enter a number.
% They clicked Cancel, or entered a character, symbols, or something else not allowed.
% Convert the default from a string and stick that into usersValue1.
usersValue1 = str2double(defaultValue{1});
message = sprintf('I said it had to be a number.\nI will use %.2f and continue.', usersValue1);
uiwait(warndlg(message));
end
% Do the same for usersValue2
If you're still stumped, let me know.
  3 个评论
Lara Adms
Lara Adms 2016-3-7
编辑:Lara Adms 2016-3-7
Please sir can you till me how can I delete my question and if that is Ok with you
Walter Roberson
Walter Roberson 2016-3-8
No, questions will not be deleted once posted, not unless they violate the terms of the site. If you wanted private consultation you should have paid a private consultant.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Image Filtering and Enhancement 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by