24小时热门版块排行榜    

Znn3bq.jpeg
查看: 535  |  回复: 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 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考博] 如果工作了想读博,可以边工作边读全日制嘛? 30+3 铁达火车 2026-05-18 5/250 2026-05-20 09:33 by tfang
[有机交流] 如何实现卤原子转化 +3 BT20230424 2026-05-15 8/400 2026-05-20 09:32 by xtlilibin
[基金申请] 河北省自然科学基金 +3 Peterchao 2026-05-18 3/150 2026-05-20 08:57 by 霸_霸
[教师之家] 上海大学实验技术岗位非升即走 +12 嘻嘻哈哈乐呵呵 2026-05-15 13/650 2026-05-20 08:34 by xli1984
[基金申请] 今年审到国自然15份,谈谈感受 +17 国自然国社科中 2026-05-17 18/900 2026-05-20 00:03 by kksky
[文学芳草园] 献血感触 +6 呀呀好傻 2026-05-19 11/550 2026-05-19 22:26 by 而立得乐
[考博] 云南大学材料与能源学院解琳课题组钙钛矿博士招生 +3 光伏爱好者 2026-05-17 5/250 2026-05-19 19:13 by 光伏爱好者
[论文投稿] Sci. Bull. 悲剧经验 +4 jyang1999 2026-05-16 4/200 2026-05-19 10:56 by maolC
[基金申请] 别被青基扩招骗了!26年科研内卷才刚刚开始 +3 国自然国社科中 2026-05-14 4/200 2026-05-19 08:48 by archvillain
[考博] 博士申请 +5 星…… 2026-05-18 6/300 2026-05-18 23:49 by 糊糊涂涂好
[基金申请] 面上本子正文33页,违规吗?会被低分嘛? +8 1234567wang 2026-05-17 10/500 2026-05-18 18:52 by zzahkj
[基金申请] 国自然上会要求 +5 无名者登山 2026-05-18 9/450 2026-05-18 17:50 by BlakeReary
[基金申请] 青C资助名额大幅增加! +12 西葫芦炒鸡蛋 2026-05-13 16/800 2026-05-18 10:02 by Equinoxhua
[硕博家园] 我在等一个没有答案的答案 +3 Love_MH 2026-05-17 3/150 2026-05-18 02:22 by 竹林孤影
[文学芳草园] 半夜喝咖啡 +3 myrtle 2026-05-15 5/250 2026-05-18 01:03 by 小沈2018
[考博] 光量子物理方向 博士招生 1人(2026.09) +3 sandyworld 2026-05-15 4/200 2026-05-17 14:38 by sandyworld
[有机交流] 求助2,4-二氯-5-嘧啶甲醛的合成方法 20+3 光吃不拉 2026-05-14 6/300 2026-05-16 19:46 by Equinoxhua
[硕博家园] 申请博士 +3 呃?呃 2026-05-15 3/150 2026-05-16 11:01 by a4742549
[考博] 26应届毕业生考博求助 +3 wo一定上岸 2026-05-13 3/150 2026-05-14 21:47 by 明海天涯
[考博] 材料类只有一篇综述能申博么 +4 乐逍遥谷 2026-05-13 4/200 2026-05-14 12:05 by zhyzzh
信息提示
请填处理意见