Blackeye 发表于 2006-1-7 13:14

[求助]matlab图象处理的问题

<P>我没学过matlab,但最近需要用到下面这个程序,对于一些语句的功能我不太懂,你各位高手赐教,不胜感激!!!!<BR>onion = imread('onion.png');<BR>peppers = imread('peppers.png');</P>
<P>imshow(onion)<BR>figure, imshow(peppers)</P>
<P><BR>% non-interactively<BR>rect_onion = ;<BR>rect_peppers = ;<BR>sub_onion = imcrop(onion,rect_onion);<BR>sub_peppers = imcrop(peppers,rect_peppers);</P>
<P>% OR</P>
<P>% interactively<BR>% = imcrop(onion); % choose the pepper below the </P>
<P>onion<BR>% = imcrop(peppers); % choose the whole onion</P>
<P>% display sub images<BR>figure, imshow(sub_onion)<BR>figure, imshow(sub_peppers)</P>
<P><BR>c = normxcorr2(sub_onion(:,:,1),sub_peppers(:,:,1));<BR>figure, surf(c), shading flat</P>
<P><BR>% offset found by correlation<BR> = max(abs(c(:)));<BR> = ind2sub(size(c),imax(1));<BR>corr_offset = [(xpeak-size(sub_onion,2))<BR>               (ypeak-size(sub_onion,1))];</P>
<P>% relative offset of position of subimages<BR>rect_offset = [(rect_peppers(1)-rect_onion(1))<BR>               (rect_peppers(2)-rect_onion(2))];</P>
<P>% total offset<BR>offset = corr_offset + rect_offset;<BR>xoffset = offset(1);<BR>yoffset = offset(2);</P>

<P>xbegin = round(xoffset+1);<BR>xend   = round(xoffset+ size(onion,2));<BR>ybegin = round(yoffset+1);<BR>yend   = round(yoffset+size(onion,1));</P>
<P>% extract region from peppers and compare to onion<BR>extracted_onion = peppers(ybegin:yend,xbegin:xend,:);<BR>if isequal(onion,extracted_onion)<BR>   disp('onion.png was extracted from peppers.png')<BR>end</P>
<P><BR>recovered_onion = uint8(zeros(size(peppers)));<BR>recovered_onion(ybegin:yend,xbegin:xend,:) = onion;<BR>figure, imshow(recovered_onion)</P>
<P><BR> = size(peppers);<BR>mask = ones(m,n);<BR>i = find(recovered_onion(:,:,1)==0);<BR>mask(i) = .2; % try experimenting with different levels of<BR>            % transparency</P>
<P>% overlay images with transparency<BR>figure, imshow(peppers(:,:,1)) % show only red plane of peppers<BR>hold on<BR>h = imshow(recovered_onion); % overlay recovered_onion<BR>set(h,'AlphaData',mask)</P>

Blackeye 发表于 2006-1-7 13:41

[求助]matlab图象处理的问题(图形简切与恢复)

<DIV class=quote>
<P><STRONG>我没学过matlab,但最近需要用到下面这个程序,对于一些语句的功能我不太懂,你各位高手赐教,不胜感激!!!!<BR></STRONG>onion = imread('onion.png');<BR>peppers = imread('peppers.png');</P>
<P>imshow(onion)<BR>figure, imshow(peppers)<STRONG>请问能否确定读出图片的区域值??</STRONG></P>
<P><BR>% non-interactively<BR>rect_onion = ;<BR>rect_peppers = ;<STRONG>怎么确定要剪切的图片的区域范围??</STRONG><BR>sub_onion = imcrop(onion,rect_onion);<BR>sub_peppers = imcrop(peppers,rect_peppers);</P>
<P>% OR</P>
<P>% interactively<BR>% = imcrop(onion); % choose the pepper below the </P>
<P>onion<BR>% = imcrop(peppers); % choose the whole onion</P>
<P>% display sub images<BR>figure, imshow(sub_onion)<BR>figure, imshow(sub_peppers)</P>
<P><STRONG>后面的好多语句不知道什么意思,恳请各位高手将每句注释一下,谢谢!!</STRONG><BR>c = normxcorr2(sub_onion(:,:,1),sub_peppers(:,:,1));<BR>figure, surf(c), shading flat</P>
<P><BR>% offset found by correlation<BR> = max(abs(c(:)));<BR> = ind2sub(size(c),imax(1));<BR>corr_offset = [(xpeak-size(sub_onion,2))<BR>               (ypeak-size(sub_onion,1))];</P>
<P>% relative offset of position of subimages<BR>rect_offset = [(rect_peppers(1)-rect_onion(1))<BR>               (rect_peppers(2)-rect_onion(2))];</P>
<P>% total offset<BR>offset = corr_offset + rect_offset;<BR>xoffset = offset(1);<BR>yoffset = offset(2);</P>
<P>xbegin = round(xoffset+1);<BR>xend   = round(xoffset+ size(onion,2));<BR>ybegin = round(yoffset+1);<BR>yend   = round(yoffset+size(onion,1));</P>
<P>% extract region from peppers and compare to onion<BR>extracted_onion = peppers(ybegin:yend,xbegin:xend,:);<BR>if isequal(onion,extracted_onion)<BR>   disp('onion.png was extracted from peppers.png')<BR>end</P>
<P><BR>recovered_onion = uint8(zeros(size(peppers)));<BR>recovered_onion(ybegin:yend,xbegin:xend,:) = onion;<BR>figure, imshow(recovered_onion)</P>
<P><BR> = size(peppers);<BR>mask = ones(m,n);<BR>i = find(recovered_onion(:,:,1)==0);<BR>mask(i) = .2; % try experimenting with different levels of<BR>            % transparency</P>
<P>% overlay images with transparency<BR>figure, imshow(peppers(:,:,1)) % show only red plane of peppers<BR>hold on<BR>h = imshow(recovered_onion); % overlay recovered_onion<BR>set(h,'AlphaData',mask)</P></DIV>
<br>

happy 发表于 2006-1-7 13:52

回复:(Blackeye)[求助]matlab图象处理的问题(图形...

<DIV class=quote><B>以下是引用<I>Blackeye</I>在2006-1-7 13:41:23的发言:</B><BR>
<DIV class=quote>
<P><STRONG>我没学过matlab,但最近需要用到下面这个程序,对于一些语句的功能我不太懂,你各位高手赐教,不胜感激!!!!<BR></STRONG>onion = imread('onion.png');<BR>peppers = imread('peppers.png');</P>
<P>imshow(onion)<BR>figure, imshow(peppers)<STRONG>请问能否确定读出图片的区域值??<BR><BR><BR><FONT color=#ff0000>imread读入的时候就已经确定大小了,矩阵的大小表示的就是图片的大小,比如:</FONT></STRONG><BR><FONT color=#ff0000>onion = imread('onion.png');<BR>=size(inion);<BR>则m表示纵向的像素点数,n表示横向的像素点数</FONT><BR></P>
<P><BR>% non-interactively<BR>rect_onion = ;<BR>rect_peppers = ;<STRONG>怎么确定要剪切的图片的区域范围??<BR><BR><FONT color=#ff0000>这个要看你自己的要求,你要去哪一部分就选取哪一部分</FONT><BR><BR><BR></STRONG><BR>sub_onion = imcrop(onion,rect_onion);<BR>sub_peppers = imcrop(peppers,rect_peppers);</P>
<P>% OR</P>
<P>% interactively<BR>% = imcrop(onion); % choose the pepper below the </P>
<P>onion<BR>% = imcrop(peppers); % choose the whole onion</P>
<P>% display sub images<BR>figure, imshow(sub_onion)<BR>figure, imshow(sub_peppers)</P>
<P><STRONG>后面的好多语句不知道什么意思,恳请各位高手将每句注释一下,谢谢!!<BR><BR><FONT color=#ff0000>请说明具体那些语句</FONT><BR><BR></STRONG><BR>c = normxcorr2(sub_onion(:,:,1),sub_peppers(:,:,1));<BR>figure, surf(c), shading flat</P>
<P><BR>% offset found by correlation<BR> = max(abs(c(:)));<BR> = ind2sub(size(c),imax(1));<BR>corr_offset = [(xpeak-size(sub_onion,2))<BR>               (ypeak-size(sub_onion,1))];</P>
<P>% relative offset of position of subimages<BR>rect_offset = [(rect_peppers(1)-rect_onion(1))<BR>               (rect_peppers(2)-rect_onion(2))];</P>
<P>% total offset<BR>offset = corr_offset + rect_offset;<BR>xoffset = offset(1);<BR>yoffset = offset(2);</P>
<P>xbegin = round(xoffset+1);<BR>xend   = round(xoffset+ size(onion,2));<BR>ybegin = round(yoffset+1);<BR>yend   = round(yoffset+size(onion,1));</P>
<P>% extract region from peppers and compare to onion<BR>extracted_onion = peppers(ybegin:yend,xbegin:xend,:);<BR>if isequal(onion,extracted_onion)<BR>   disp('onion.png was extracted from peppers.png')<BR>end</P>
<P><BR>recovered_onion = uint8(zeros(size(peppers)));<BR>recovered_onion(ybegin:yend,xbegin:xend,:) = onion;<BR>figure, imshow(recovered_onion)</P>
<P><BR> = size(peppers);<BR>mask = ones(m,n);<BR>i = find(recovered_onion(:,:,1)==0);<BR>mask(i) = .2; % try experimenting with different levels of<BR>            % transparency</P>
<P>% overlay images with transparency<BR>figure, imshow(peppers(:,:,1)) % show only red plane of peppers<BR>hold on<BR>h = imshow(recovered_onion); % overlay recovered_onion<BR>set(h,'AlphaData',mask)</P></DIV><BR></DIV>
<br>

Blackeye 发表于 2006-1-7 15:19

多谢您的指导,我还有下面这些语句的功能不清楚,请赐教~~~

(1)c = normxcorr2(sub_onion(:,:,1),sub_peppers(:,:,1));<BR>normxcorr2是实现什么功能??(:,:,1)是什么参数??<BR><BR>以下也大多是一些函数的功能不知道<BR>(2) = max(abs(c(:)));<BR>    = ind2sub(size(c),imax(1));<BR>   corr_offset = [(xpeak-size(sub_onion,2))<BR>                  (ypeak-size(sub_onion,1))];<BR><BR>谢谢!!!<BR><BR>(3)<BR> = size(peppers);<BR>mask = ones(m,n);<BR>i = find(recovered_onion(:,:,1)==0);<BR>mask(i) = .2; % try experimenting with different levels of<BR>            % transparency<BR><BR>

suffer 发表于 2006-1-7 17:51

回复:(Blackeye)多谢您的指导,我还有下面这些语句...

<DIV class=quote><B>以下是引用<I>Blackeye</I>在2006-1-7 15:19:08的发言:</B><BR>(1)c = normxcorr2(sub_onion(:,:,1),sub_peppers(:,:,1));<BR>normxcorr2是实现什么功能??(:,:,1)是什么参数??<BR><BR>以下也大多是一些函数的功能不知道<BR>(2) = max(abs(c(:)));<BR>    = ind2sub(size(c),imax(1));<BR>   corr_offset = [(xpeak-size(sub_onion,2))<BR>                  (ypeak-size(sub_onion,1))];<BR><BR>谢谢!!!<BR><BR>(3)<BR> = size(peppers);<BR>mask = ones(m,n);<BR>i = find(recovered_onion(:,:,1)==0);<BR>mask(i) = .2; % try experimenting with different levels of<BR>            % transparency<BR><BR></DIV>
<br><BR><BR>help 或者 doc自己啊
页: [1]
查看完整版本: [求助]matlab图象处理的问题