24小时热门版块排行榜    

查看: 562  |  回复: 0

sacredli

新虫 (初入文坛)

[求助] 在线求助 大神帮我看一下 这段程序有什么问题 紧急!!!!!!

function idisp(z, clip, ncmap)

if nargin < 3,
    %         ncmap = 64;
    ncmap = 256;
end

if (nargin > 0) & ~isstr(z),
  
   
    clf
    colormap(gray(ncmap))
    n = ncmap;
    if nargin == 2,
        if length(clip) == 2,
            z(find(z<clip(1))) = clip(1);
            z(find(z>clip(2))) = clip(2);
        elseif length(clip) == 1,
            z(find(z>clip)) = clip;
        end
    end
    hi = image(z);
    hh = max(max(z));
    mm = min(min(z));
    [r1 c1] = find(z == hh);
    [r2 c2] = find(z == mm);
    set(hi, 'CDataMapping', 'scaled');
    htf = uicontrol(gcf, ...
        'style', 'text', ...
        'units',  'norm', ...
        'pos', [.8 .93 .2 .07], ...
        'string', '' ...
        );
    htf1= uicontrol(gcf, ...
        'style', 'text', ...
        'units',  'norm', ...
        'pos', [0 0 0.2 .06], ...
        'string', '' ...
        );
    htf2= uicontrol(gcf, ...
        'style', 'text', ...
        'units',  'norm', ...
        'pos', [0.7 0 0.3 .06], ...
        'string', '' ...
        );
    ud = [gca htf hi axis htf2 r2(1) c2(1) mm htf1 r1(1) c1(1) hh];
    set(gca, 'UserData', ud);
    set(hi, 'UserData', ud);
   
    hpb=uicontrol(gcf,'style','push','string','line', ...
        'units','norm','pos',[0 .93 .1 .07], ...
        'userdata', ud, ...
        'callback', 'idisp(''line'')');
    hzm=uicontrol(gcf,'style','push','string','zoom', ...
        'units','norm','pos',[.1 .93 .1 .07], ...
        'userdata', ud, ...
        'callback', 'idisp(''zoom'')');
    huz=uicontrol(gcf,'style','push','string','unzoom', ...
        'units','norm','pos',[.2 .93 .15 .07], ...
        'userdata', ud, ...
        'callback', 'idisp(''unzoom'')');
   
    set(hi, 'UserData', ud);
    set(gcf, 'WindowButtonDownFcn', 'idisp(''down'')');
    set(gcf, 'WindowButtonUpFcn', 'idisp(''up'')');
    return;
end


if nargin == 0,
    h = get(gcf, 'CurrentObject'); % image
    ud = get(h, 'UserData');                % axis
    h_ax = ud(1);        % axes
    tf = ud(2);        % string field
    hi = ud(3);        % the image
    cp = get(h_ax, 'CurrentPoint');
    x = round(cp(1,1));
    y = round(cp(1,2));
    imdata = get(hi, 'CData');
    set(tf, 'String', ['(' num2str(y) ', ' num2str(x) ') = ' num2str(imdata(y,x))]);
   
    htf1 = ud(end-3);       
    r1 = ud(end-2);       
    c1 = ud(end-1);       
    hh = ud(end);
    htf2 = ud(end-7);       
    r2 = ud(end-6);       
    c2 = ud(end-5);       
    mm = ud(end-4);
    set(htf1, 'String', ['(' num2str(r1) ', ' num2str(c1) ') = ' num2str(hh)]);
    set(htf2, 'String', ['(' num2str(r2) ', ' num2str(c2) ') = ' num2str(mm)]);
    drawnow
elseif nargin == 1,
    switch z,
        case 'down',
            % install pixel value inspector
            set(gcf, 'WindowButtonMotionFcn', 'idisp');
            idisp
            
        case 'up',
            set(gcf, 'WindowButtonMotionFcn', '');
            
        case 'line',
            h = get(gcf, 'CurrentObject'); % push button
            ud = get(h, 'UserData');
            ax = ud(1);        % axes
            tf = ud(2);        % string field
            hi = ud(3);        % the image
            set(tf, 'String', 'First point');
            [x1,y1] = ginput(1);
            x1 = round(x1); y1 = round(y1);
            set(tf, 'String', 'Last point');
            [x2,y2] = ginput(1);
            x2 = round(x2); y2 = round(y2);
            set(tf, 'String', '');
            imdata = get(hi, 'CData');
            dx = x2-x1; dy = y2-y1;
            if abs(dx) > abs(dy),
                x = min(x1,x2):max(x1,x2);
                y = round(dy/dx * (x-x1) + y1);
                nim = size(x,2);
                for kn = 1:nim
                    imgout(kn) = imdata(y(kn),x(kn));
                end
                figure;plot(x,imgout); xlabel('Coordinate (X)')
            else
                y = min(y1,y2):max(y1,y2);
                x = round(dx/dy * (y-y1) + x1);
                nim = size(y,2);
                for kn = 1:nim
                    imgout(kn) = imdata(y(kn),x(kn));
                end
                figure;plot(y,imgout); xlabel('Coordinate (Y)')
            end
                 
        case 'zoom',
            h = get(gcf, 'CurrentObject'); % push button
            ud = get(h, 'UserData');
            ax = ud(1);        % axes
            tf = ud(2);        % string field
            hi = ud(3);        % the image
            set(tf, 'String', 'First point');
            [x1,y1] = ginput(1);
            x1 = round(x1); y1 = round(y1);
            set(tf, 'String', 'Last point');
            [x2,y2] = ginput(1);
            x2 = round(x2); y2 = round(y2);
            set(tf, 'String', '');
            axes(ax);
            axis([x1 x2 y1 y2]);
        case 'unzoom',
            h = get(gcf, 'CurrentObject'); % push button
            ud = get(h, 'UserData');
            h_ax = ud(1);        % axes
            axes(h_ax);
            axis(ud(4:7));
    end
end
回复此楼
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

智能机器人

Robot (super robot)

我们都爱小木虫

找到一些相关的精华帖子,希望有用哦~

科研从小木虫开始,人人为我,我为人人
相关版块跳转 我要订阅楼主 sacredli 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[硕博家园] 读博的好处 +3 lnee 2026-08-11 3/150 2026-08-11 18:10 by 希望我好好的
[基金申请] 听说今天filecode变了 +26 布布和一二 2026-08-06 49/2450 2026-08-11 13:18 by WH3796
[基金申请] FileCode能看出啥? +7 要乐观耀哥 2026-08-10 17/850 2026-08-11 10:50 by 要乐观耀哥
[基金申请] filecode +9 documentary 2026-08-10 9/450 2026-08-11 10:08 by wk7465
[基金申请] 我的国基提前知道中了,可是同事的操作让我实在接受不了,怎么会有这样的人 +8 家与远方 2026-08-10 13/650 2026-08-11 09:49 by 家与远方
[基金申请] 确定了,国自然21号放榜 +6 布布和一二 2026-08-10 7/350 2026-08-10 19:15 by 2000zf36392
[基金申请] 关于代码变化问题,想知道的进来 +17 且听虎啸 2026-08-07 24/1200 2026-08-10 18:35 by zhangduo2008
[基金申请] 关于Filecode分析方法 +3 majunge000 2026-08-10 3/150 2026-08-10 15:46 by lch2012
[基金申请] 国自然结果 +4 Vierhys 2026-08-10 8/400 2026-08-10 15:06 by Vierhys
[基金申请] 好奇怪的filecode +4 布布和一二 2026-08-08 5/250 2026-08-10 14:20 by 冰心玉壶晴
[基金申请] 据悉今年马上要出结果了 +7 瞬息宇宙 2026-08-10 8/400 2026-08-10 12:42 by Vivilian
[基金申请] filecode与中标关系的预测 +5 布布和一二 2026-08-07 5/250 2026-08-09 16:15 by 袁向阳007
[基金申请] 关于豆爷回答的JTJC与%2F数量 +5 yang182083 2026-08-06 7/350 2026-08-08 18:29 by zhanghaozhu
[基金申请] 国基金的申报应该改成非等额制,评价高的钱多评价低的钱少,但是增加资助率 +7 a089 2026-08-07 7/350 2026-08-08 18:05 by gltch
[基金申请] 固定端突然变了,今天 +6 archvillain 2026-08-06 10/500 2026-08-07 16:03 by 医学老男孩
[基金申请] filecode变化情况 +6 布布和一二 2026-08-07 22/1100 2026-08-07 14:45 by 且听虎啸
[基金申请] 大家散了吧,后缀研究没有意义,别浪费时间了,过好目前的每一天,不要焦虑 +5 Tide man 2026-08-06 7/350 2026-08-07 13:11 by 医学老男孩
[基金申请] filecode +14 等待解的谜 2026-08-06 19/950 2026-08-07 12:20 by wlwhappy
[基金申请] filecode +8 布布和一二 2026-08-06 11/550 2026-08-06 20:41 by tangpu318
[基金申请] 好消息?这个有何含义??? +8 Tide man 2026-08-05 10/500 2026-08-05 16:14 by xmuxiaoyu
信息提示
请填处理意见