can someone give me the source code for imgaussfilt function.

26 views (last 30 days)
Since I am using matlab 2013a I don't have imgaussfilt function. I want to use that function with my current work. So I want to create that function in my matlab file. If someone can share me the source code of the imgaussfilt.m file it will be very helpful. thanks
  1 Comment
Steven Lord
Steven Lord on 1 Nov 2017
Jeganson Durai, please do not post code included in MathWorks toolboxes. I deleted the comment to which you had attached the file.

Sign in to comment.

Accepted Answer

Steven Lord
Steven Lord on 1 Dec 2015
IMGAUSSFILT was introduced in Image Processing Toolbox in release R2015a as called out in the item "Optimized function for Gaussian filtering" in the Release Notes. You will need to use that release or later and have Image Processing Toolbox installed in order to use that function. If you are using R2015a or later and have Image Processing Toolbox installed, that function is implemented as a MATLAB function file and so you can read the code. But no one is going to simply provide it to you and even if they did, it likely would not work without other functions in the toolbox.

More Answers (3)

Walter Roberson
Walter Roberson on 1 Dec 2015
Yes, no problem. All you need to do is get a job with Mathworks and you will have access to the source.
If getting a job at Mathworks is a problem for some reason, then there is always the alternative of buying Mathworks. All of Mathworks -- the entire company. Mathworks is privately held, not on the Stock Exchange, so you would have to convince the current owners to sell, which might be a little difficult. My advice on that has always been that a $US 5 million non-refundable deposit will at least get you a meeting in which they would listen to your buy-out proposal.
Note: "get a job at Mathworks" is the response of Mathworks employees, the official way to get access to the source. The possibility of buying out Mathworks for a couple of billion dollars is my own suggestion.

Daniel Marelius Bjørnstad
Edited: Daniel Marelius Bjørnstad on 8 Jun 2017
I think have found a way to do the same thing imgaussfilt is doing. I think the function gausswin is still in the imaging toolbox though, but this should illuminate what is going on anyway.
function arr_out = gaussian(arr, sigma)
arr = double(arr);
% Default value of alpha in gausswin is 2.5.
alpha = 2.5;
% The number of points included in the window.
% To be honest I dont understand this completely, but I changed around
% an equation in the documentation for gausswin and it seems to fit.
% Bottom line is that we create a window that has enough points to
% include the shape of gaussian.
N = round(2*alpha*sigma);
% Create the window.
filter_arr = gausswin(N, alpha);
% Normalize to ensure output is correct after convolution.
filter_arr = filter_arr/sum(filter_arr);
% Padd the array with the start end end of the array,
% this is important to get the same results as
% imgaussfilt. Looks good for pictures.
pad_length = ceil(N/2);
% Support both ways of having 1d arrays because matlab is annoying.
if size(arr,1) == 1
padding = ones(1,pad_length);
arr = [padding*arr(1), arr, padding*arr(end)];
else
padding = ones(pad_length,1);
arr = [padding*arr(1); arr; padding*arr(end)];
end
% Do the filtering.
arr_out = conv(arr, filter_arr, 'same');
% Remove the padding we introduced.
arr_out = arr_out(pad_length+1:end-pad_length);
end

Image Analyst
Image Analyst on 1 Dec 2015
You can see some of it this way.
>> edit imgaussfilt.m
Perhaps that will be enough for you.

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!