⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lhidrawregion.m

📁 This code can parse any image in matlab. Very elaborate code
💻 M
字号:
function img = LHIdrawregion(varargin)
% Draw the subgraphs in an image.
% LHIdrawsubgraph(annotation, img)
% LHIdrawsubgraph(database, ndx, HOMEIMAGES)
%
% Example:
%   [annotation, img] = LHIread(filename, HOMEIMAGES)
%   LHIdrawsubgraph(annotation, img)

switch length(varargin)
   case 2
       annotation = varargin{1};
       img = varargin{2};
   case 3
       D = varargin{1};
       ndx = varargin{2};
       
       if ndx>length(D)
           error('Index out of range');
       end
       
       HOMEIMAGES = varargin{3};

       annotation = D(ndx).annotation;
       %img = imread(fullfile(HOMEIMAGES, annotation.folder, annotation.filename));
       img = LMimread(D, ndx, HOMEIMAGES); % Load image
   otherwise
       error('Input arguments not right.')
end

imgsize = size(img);
if ((ndims(imgsize)==3))
    img = grb2gray(img);
end
% Draw each object (only non deleted ones)
if isfield(annotation, 'object')
   Nobjects = length(annotation.object); n=0;
   for i = 1:Nobjects
       if (isfield(annotation.object(i),'regions'))
           img =drawImageObject(img, annotation.object(i));
       end
       Nparts = length(annotation.object(i).parts);
       for j=1:Nparts
           if(isfield(annotation.object(i).parts(j),'regions'))
               img = drawImageObject(img, annotation.object(i).parts(j));
               %text(0,0,annotation.object(i).parts(j).name);
           end
       end
   end
end


function img = drawImageObject(img,object)
Nregions = length(object.regions);
%Nsubgraphs = length(object.subgraphs);
[height,width]=size(img);
h = 0;
for i = 1:Nregions
    [X,Y] = getLHIpoints(object.regions(i));
    X(X<1)=1; X(X>width)=width; Y(Y<1)=1; Y(Y>height)=height;
    for k = 1:(length(X)-1),
        img = func_DrawLine(img, Y(k),X(k),Y(k+1),X(k+1),255);
    end
    img = func_DrawLine(img,Y(end),X(end),Y(1),X(1),255);
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -