How to import images to this function? need help
1 回表示 (過去 30 日間)
古いコメントを表示
function sp = LoG(varargin)
% USAGE:
% sp = LoG(<input image>, <minimum radius>, <maximal raidus> , <detection threshold>);
% Get arguments and/or default values
[im, Rmin, Rmax, peakthr] = checkargs(varargin(:));
if size(im,3) >1
img = rgb2gray(im);
else
img = im;
end
img = double(img);
block = [];
for s = Rmin:Rmax
h = -(s^2) * fspecial('log',s*5,s); % minus just so max is what we want
result = imfilter(img,h,'replicate');
% creates a scale space block to find location and scale of nuclei
block = cat(3,block, result);
end
[Cxy, indx] = max(block,[],3);
G = fspecial('gaussian', 20, 2);
Cxy_g = imfilter(Cxy, G,'symmetric');
ir_max = imregionalmax(Cxy_g);
ir_max = ir_max.*Cxy_g;
ir_med = imdilate(ir_max,strel('disk',min(Rmax,6),0));
ir_max = (ir_med == ir_max).*ir_max;
[r, c] = find(ir_max>peakthr);
sp = struct('radius',[],'x',[],'y',[],'px',[],'py',[],'resp',0);
for p = 1:length(r)
sp(p).x = c(p);
sp(p).y = r(p);
sp(p).radius = indx(r(p),c(p)) + Rmin - 1;
sp(p).resp = Cxy(r(p),c(p));
end
0 件のコメント
採用された回答
Image Analyst
2019 年 3 月 31 日
You'd do
im = varargin{1};
minRadius = varargin{2}
maxRadius = varargin{3}
11 件のコメント
Walter Roberson
2019 年 3 月 31 日
You cannot call that code just passing in a single scalar value. You must pass in at least 4 values.
- The first must be an image array -- not the name of an image, but the content of the image, such as the result of imread() of an image
- the second must be the minimum radius to use
- the third must be the maximum radius to use
- the fourth must be the dection threshold
Image Analyst
2019 年 3 月 31 日
The code I gave you (and attach here) does work if you put it in, and call the functions with the variables in the right order: image, minRadius, maRadius.
You can't just pass in 5, which is one of the radii, without passing in things that come before it also. For example if you pass in the min radius, you must pass in the image. So here are the ways you can call it
sp = LoG(grayImage) % Pass in image but no radii
sp = LoG(grayImage, 5) % Pass in image and min radius, but no max radius
sp = LoG(grayImage, 5, 10) % Pass in everything you can, in proper order.
but you cannot do this:
sp = LoG(5) % Pass in either min or max radius with no image first.
as you did.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!