Info

This question is closed. Reopen it to edit or answer.

Need help translating MATLAB to C

1 view (last 30 days)
dee koshy
dee koshy on 1 Mar 2012
Closed: MATLAB Answer Bot on 20 Aug 2021
function [normim, mask, maskind] = attemptridgesegment(im, blksze, thresh)
im = normalize(im,0,1);
fun = @(block_struct)std2(block_struct.data) * ones(size(block_struct.data));
stddevim = blockproc(im, [blksze blksze], fun);
mask = stddevim > thresh;
maskind = find(mask);
im = im - mean(im(maskind));
normim = im/std(im(maskind));
function[n] = normalize(f, reqmean, reqvar)
if (nargin == 1)
if ndims(f)==2
if ~isa(f,'double')
f = double(f); end
n = f - min(f(:));
n = n/max(n(:));
end
end
if (nargin ==3)
f = double(f);
f = f - mean(f(:));
f = f/std(f(:));
n = reqmean + f*sqrt(reqvar);
end
  1 Comment
Walter Roberson
Walter Roberson on 1 Mar 2012
I don't see any good reason for the multiplication by ones() -- that just replicates the data, which isn't going to change the mean since everything is going to be replicated the same number of times. I suppose it would make a difference to the standard deviation, but my instinct is that you are worsening your std with the replication.

Answers (0)

Community Treasure Hunt

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

Start Hunting!