把下面Matlab代码转成Python：function Result = WaveletFilter(image,aMinRadius,aMaxRadius,scaleThreshold)

% Based on the code of Institut Pasteur

% Image : input image matrix, 8-bit or 16-bit grey
% aMinRadius : minimal expected spot radius in pixel
% aMaxRadius : maximal expected spot radius in pixel
% scaleThreshold : N x Sigma of Standard Deviation (we can begin with 2 or 3 ) 


height = size(image,1);
width = size(image,2);
Result = zeros(height, width);

availableScale = [1, 3, 7, 13, 25]; % in pixel
scalesList = logical([false, false, false, false, false]);

%Set scaleList accroding to min and max radius
isEnable =false;
for i = 1:5
    if availableScale(i) >= aMinRadius * 2 && availableScale(i) <= aMaxRadius * 2
        scalesList(i) = true;
        isEnable = true;
    end
end

if ~isEnable
    for i = 1:5
        if availableScale(i) >= aMinRadius * 2
            scalesList(i - 1) = true;
            break;
        end
    end
end





maxScale = 0;
% minScale = 0;
% find the max scale number in scalesList[]
findMin = false;
for i = 1:length(scalesList)
    if scalesList(i)
        if ~findMin
            findMin = true;
            % minScale = i + 1;
        end
        maxScale = i;
    end
end
if maxScale == 0
    return;
end

% check image dimensions
minSize = 5 + (2^(maxScale - 1) - 1) * 4;
if width < minSize || height < minSize
    return;
end
image = image';
pixels = image(:);
% decompose the image
scales = WaveletScales2D(pixels, width, height, maxScale);
coefficients = b3WaveletCoefficients2D(scales, pixels, maxScale);
% Apply threshold to coefficients but not last one (residual)
for i = 1:(size(coefficients,1)-1)
    coefficients(i,:) = filter_wat(coefficients(i,:), i, maxScale, scalesList, scaleThreshold);
end

% fill of 0 the residual image
coefficients(end,:)= 0;

 Arrayout = SpotConstruction2D(coefficients, maxScale, width * height, scalesList);
 
 Result = reshape (Arrayout,width,height);
 Result = Result';
end




% Wavelet scale images for a 2D image (Copy from Institut Pasteur)
function resArray = WaveletScales2D(dataIn, w, h, numScales)

% step between non zero coefficients of the convolution kernel
stepS = 0;
resArray = zeros(numScales, numel(dataIn));
prevArray = dataIn; % array to filter, original data for the first scale
currentArray = []; % filtered array

% for each scale
for s = 1:numScales
    stepS = 2^(s - 1); % compute the step between non zero coefficients of the convolution kernel = 2^(scale-1)
    
    % convolve along the x direction and swap dimensions
    currentArray = filterAndSwap2D(prevArray, w, h, stepS);
    
    % swap current and previous array pointers
    if s == 1
        prevArray = currentArray; % the filtered array becomes the array to filter
        currentArray = zeros(w * h, 1); % allocate memory for the next dimension filtering (preserve original data)
    else
        tmp = currentArray;
        currentArray = prevArray; % the filtered array becomes the array to filter
        prevArray = tmp; % the filtered array becomes the array to filter
    end
    
    % convolve along the y direction and swap dimensions
    currentArray = filterAndSwap2D(prevArray, h, w, stepS); % swap size of dimensions
    
    % swap current and previous array pointers
    tmp = currentArray;
    currentArray = prevArray;
    prevArray = tmp;
    
    resArray(s, :) = zeros(w * h, 1); % allocate memory to store the filtered array
    resArray(s, :) = prevArray;
end

end


function waveletCoefficients = b3WaveletCoefficients2D(scaleCoefficients, originalImage, numScales)

% maxScales wavelet images to store, + one image for the low pass residual
waveletCoefficients = zeros(numScales + 1, numel(originalImage));

% compute wavelet coefficients as the difference between scale coefficients of subsequent scales
iterPrev = originalImage; % the finest scale coefficient is the difference between the original image and the first scale.

j = 1;
while j <= numScales
    iterCurrent = scaleCoefficients(j,:);
    wCoefficients = zeros(1,numel(originalImage));
    for i = 1:numel(originalImage)
        wCoefficients(i) = iterPrev(i) - iterCurrent(i);
    end
    waveletCoefficients(j,:) = wCoefficients;
    iterPrev = iterCurrent;
    j = j + 1;
end

% residual low pass image is the last wavelet Scale
waveletCoefficients(numScales+1,:) = scaleCoefficients(numScales,:);

end