# 程序代写Java C++ C Python C#matlab php js软件编程 留学生

function Gravit = Gravitat(Gray_image)
% finds out forces acting on pixels from other pixels
[Rows, Cols] = size(Gray_image);
Gray_image = double(Gray_image);

% creating the filter
Wind = 3;
for i=1:2*Wind-1
for j=1:2*Wind-1
Filter(i, j) = exp(-abs(Wind-i) - abs(Wind-j));
end
end
Filter(Wind, Wind) = 0;

Gravit = zeros(size(Gray_image(Wind:Rows-Wind+1, Wind:Cols-Wind+1)));
for i=1:2*Wind-1
for j=1:2*Wind-1
Gravit = Gravit + Filter(i, j) * ...
exp(-abs(Gray_image(Wind:Rows-Wind+1, Wind:Cols-Wind+1) - ...
Gray_image(i:Rows-Wind+1+i-Wind, j:Cols-Wind+1+j-Wind)));
end

end

function [New_image, Sorted_modes] = ...
Gray_segm (Gray_image, Window_radius, Min_group_size)
% Gray_segment - segment a gray-level image according to Meer's algorithm
% reads image from the file, finds significant maxima by mean shift algo
% (to generalize to the case of 3-d vectors), groups all the pixels
% whose color falls within the given interval (with peak being the
% center, and Window_radius being the radius),
% Min_group_size : need at least that many pixels to qualify for a color
clear;
clc;
figure,imshow(Gray_image);
[Rows,Cols]=size(Gray_image);
Min_image_size = 0.005*Rows*Cols; % to stop when image is small
Gray_image = double(Gray_image);
% % creating a new array - color based
% Cumulative = sparse(1, max(max(Gray_image))+1);
% for i=1:Rows
%    for j=1:Cols
%       Cumulative(Gray_image(i, j)+1) = Cumulative(Gray_image(i, j)+1)+1;
%    end
% end

% Cumulative(1) = 0; % corresponds to only manually zeroed out regions
% k = 0; L = length(Cumulative);
% while sum(Cumulative) > Min_image_size
%    Non_zero_pos = find(Cumulative > 0);
%    if length(Non_zero_pos) == 0
%       break;
%    end
%
%    Initial = Non_zero_pos(1);
%    [Mode, Number_values] = M_shift1(Cumulative, Window_radius, Initial);
%    Mode = full(round(Mode));
%
%    if Number_values > Min_group_size% good group
% k = k+1;
%       Modes(k) = Mode;
%       zeros(size(Cumulative(max(1, Mode-Window_radius): ...
%    else
%       zeros(size(Cumulative(max(1, Initial-Window_radius): ...
%    end
% end

% Sorted_modes = sort(Modes);
% New_image = zeros(size(Gray_image));
% for i=1:k
% To_group = find((Gray_image >= Sorted_modes(i)-Window_radius)...
% & (Gray_image < Sorted_modes(i)+Window_radius));
% New_image(To_group) = i;
% end
% % Gray_image == 0 added to provide for background detection
% To_zero = find(Gray_image == 0);
% New_image(To_zero) = 0;

## 联系我们

联系人：李技术

手机：15601902705

电话：15601902705

邮箱：1747812398@qq.com

地址： 上海市闵行区东川路800号