MATLAB 板


LINE

我利用m_map畫圖工具包,畫了一個太平洋的海表溫度衛星圖。但是我想要在圖中加一條 contour等溫線圖,像下圖: http://i.imgur.com/of2OiPr.png 那一條黑線是29度的等溫線圖. 可是,我畫出來卻是像這樣子: http://i.imgur.com/APtHGik.png 我知道是解析度太高的關係,才會變這樣.我們老師說要把資料平滑化,才可以畫出平滑的 contour圖,所以想請教各位網兄,會不會寫這一段平滑化的程式, 老師說說把九個像素的資料點(像九宮格)一樣,把這九格的資料平均, 一次移動一小格,做移動平均,這樣子的話,只會損失上,下,左,右的一排, 又可以達到把數字平均,就可以畫出平滑的contour了,謝謝, 但我,我跟本是matlab的門外漢,不知道怎麼去寫,請教各位了,百拜,感激不盡. 原始衛星資料是MODIS NSST,網址是: http://oceandata.sci.gsfc.nasa.gov/MODIST/Mapped/Monthly/4km/NSST/ 程式碼如下: 下載:https://dl.dropboxusercontent.com/u/5505203/sst_l3_cut6.m clc clear all % Ocean colour data from http://seawifs.gsfc.nasa.gov/SEAWIFS.html % % Take a 4km weakly average dataset and plot a map for the Strait of % Georgia and outer coast. Note that most of this code is used % for reading in and subsetting the data. path='D:\Contour test\'; %貼上資料及程式所放的資料夾路徑 cd(path); %前往路徑的資料夾 %製作資料夾 mkdir 140E-180E-15S-15N %指定經緯度及路徑 l.path=[path '140E-180E-15S-15N\']; %(1) 140E-180E-15S-15N 最大範圍 l.lon=[130 210]; l.lat=[-20 20]; b = dir('*L3m**NSST*'); for i=1:length(b); % Note - This is probably not the most efficient way to read and % handle HDF data, but I don't usually do this... % First, get the attribute data PI=hdfinfo(b(i).name); % And write it into a structure pin=[]; for k=1:60, nm=PI.Attributes(k).Name;nm(nm==' ')='_'; if isstr(PI.Attributes(k).Value), pin=setfield(pin,nm,PI.Attributes(k).Value); else pin=setfield(pin,nm,double(PI.Attributes(k).Value)); end end; for path_j=1 % lon/lat of grid corners lon=[pin.Westernmost_Longitude:pin.Longitude_Step:pin.Easternmost_Longitude]; lat=[pin.Northernmost_Latitude:-pin.Latitude_Step:pin.Southernmost_Latitude]; if l.lon(2)>=180 lon(lon<0) = lon(lon<0)+360; lon = [lon(4321:8640) lon(1:4320)]; end % Get the indices needed for the area of interest [mn,ilt]=min(abs(lat-max(l(path_j).lat))); [mn,ilg]=min(abs(lon-min(l(path_j).lon))); ltlm=ceil(diff(l(path_j).lat)/pin.Latitude_Step); lglm=ceil(diff(l(path_j).lon)/pin.Longitude_Step); % load the subset of data needed for the map limits given if l.lon(2)>=180 P=hdfread(b(i).name,'l3m_data','Index',{[],[],[]}); P=[P(:,4321:8640) P(:,1:4320)]; P=P(ilt:(ilt+ltlm),ilg:(ilg+lglm)); else P=hdfread(b(i).name,'l3m_data','Index',{[ilt ilg],[],[ltlm+1 lglm+1]}); %+1為避免周圍出現空白 end % Convert data into log(Chla) using the equations given. Blank no-data. P=double(P); P(P==65535)=NaN; P=(pin.Slope*P+pin.Intercept); LT=lat(ilt+[0:ltlm]);LG=lon(ilg+[0:lglm]); [Plg,Plt]=meshgrid(LG,LT); % Draw the map... cd(l(path_j).path) clf; %開啟畫圖程式 m_proj('miller','lon',l(path_j).lon,'lat',l(path_j).lat); %設定投影方式 m_pcolor(Plg,Plt,P); %畫出圖形 shading flat; %去除網格 hold on m_contourf(Plg,Plt,P,[29 29],'color','k'); %畫某一特定值等值線時,[ ] 內兩數字要相同 hold off m_gshhs_i('color','k'); m_grid('tickdir','out'); % m_grid('linewi',2,'tickdir','out'); % m_grid('box','fancy','tickdir','out'); set(gca,'Clim',[20,30]); % 限定上限30下限20 h=colorbar; set(get(h,'ylabel'),'String','Temperature (^{o}C)'); set(h,'ytick',[ 20:2:30 ],... 'yticklabel',[ 20:2:30 ],... 'tickdir','out','fontsize',9); title(['MODIS SST ' datestr(datenum(pin.Period_Start_Year,1,0)+pin.Period_Start_Day,26) ' -> ' ... datestr(datenum(pin.Period_End_Year,1,0)+pin.Period_End_Day,26)],... 'fontsize',14,'fontweight','bold'); saveas(gcf,... ['SST4-' datestr(datenum(pin.Period_Start_Year,1,0)+pin.Period_Start_Day,29) '--' ... datestr(datenum(pin.Period_End_Year,1,0)+pin.Period_End_Day,29) '.png'],'png'); cd(path); end disp('done.'); end % clear all --



※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 122.116.82.166
1F:推 kurt28:Moving average? 02/22 23:35
2F:推 peace0907:一張圖片根據他的pixel數會有一個對應大小的矩陣 02/24 15:11
3F:→ peace0907:然後把那個矩陣每個element做老師說的操作試試 02/24 15:12
4F:推 JamesChen:那個叫 kernel 02/25 23:46
5F:→ JamesChen:查一下影像處理的 kernel 就懂了 02/25 23:46







like.gif 您可能會有興趣的文章
icon.png[問題/行為] 貓晚上進房間會不會有憋尿問題
icon.pngRe: [閒聊] 選了錯誤的女孩成為魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一張
icon.png[心得] EMS高領長版毛衣.墨小樓MC1002
icon.png[分享] 丹龍隔熱紙GE55+33+22
icon.png[問題] 清洗洗衣機
icon.png[尋物] 窗台下的空間
icon.png[閒聊] 双極の女神1 木魔爵
icon.png[售車] 新竹 1997 march 1297cc 白色 四門
icon.png[討論] 能從照片感受到攝影者心情嗎
icon.png[狂賀] 賀賀賀賀 賀!島村卯月!總選舉NO.1
icon.png[難過] 羨慕白皮膚的女生
icon.png閱讀文章
icon.png[黑特]
icon.png[問題] SBK S1安裝於安全帽位置
icon.png[分享] 舊woo100絕版開箱!!
icon.pngRe: [無言] 關於小包衛生紙
icon.png[開箱] E5-2683V3 RX480Strix 快睿C1 簡單測試
icon.png[心得] 蒼の海賊龍 地獄 執行者16PT
icon.png[售車] 1999年Virage iO 1.8EXi
icon.png[心得] 挑戰33 LV10 獅子座pt solo
icon.png[閒聊] 手把手教你不被桶之新手主購教學
icon.png[分享] Civic Type R 量產版官方照無預警流出
icon.png[售車] Golf 4 2.0 銀色 自排
icon.png[出售] Graco提籃汽座(有底座)2000元誠可議
icon.png[問題] 請問補牙材質掉了還能再補嗎?(台中半年內
icon.png[問題] 44th 單曲 生寫竟然都給重複的啊啊!
icon.png[心得] 華南紅卡/icash 核卡
icon.png[問題] 拔牙矯正這樣正常嗎
icon.png[贈送] 老莫高業 初業 102年版
icon.png[情報] 三大行動支付 本季掀戰火
icon.png[寶寶] 博客來Amos水蠟筆5/1特價五折
icon.pngRe: [心得] 新鮮人一些面試分享
icon.png[心得] 蒼の海賊龍 地獄 麒麟25PT
icon.pngRe: [閒聊] (君の名は。雷慎入) 君名二創漫畫翻譯
icon.pngRe: [閒聊] OGN中場影片:失蹤人口局 (英文字幕)
icon.png[問題] 台灣大哥大4G訊號差
icon.png[出售] [全國]全新千尋侘草LED燈, 水草

請輸入看板名稱,例如:Tech_Job站內搜尋

TOP