2015-12-28 106 views
0

你好我每個人都在一個眼睛在mat實驗室的3D模型和所有我想出來的是一個扁平的球體,我應該添加到它做出一個現實的眼睛模型?Matlab中的3D眼圖

[x,y,z] = sphere(); 
r = 5; 
surf(r*x, r*y, r*z+2, 'edgecolor', 'none') 
axis equal, grid off, axis off 

hold on 
[x,y,z] = sphere;  
x = x(15:end,:);  
y = y(15:end,:);  
z = z(15:end,:);  
rx = 4;ry = 4;rz = 8; 
surf(rx*x,ry*y,rz*z); 
axis equal; 

set(gcf, 'Renderer', 'OpenGL'); 
shading interp, material shiny, lighting phong, lightangle(0, 55) 

這是什麼,我都試過了代碼,但還沒有接近我期待

3d eye

+2

雙方合作諒解備忘錄se,人體模型和惰性氣體是人類的好模型。您需要哪一個取決於應用程序以及您想要建模的內容。那麼你以後是什麼樣的模特? (不管怎麼說,你的問題可能是非常關注的話題) –

+0

無論如何,你可能需要[一個大的球體和一個突出的小球體](https://www.google.hu/search?q=3d +眼+模型&客戶= ubuntu的&HS = CZ3&信道= FS&源= LNMS&TBM = isch)。 –

+0

@AndrasDeak,感謝您的回覆,我編輯了我的問題,並上傳了迄今爲止完成的圖像,現在可以幫助我更好地實現更好的模型。 –

回答

2

你的問題沒有得到很好的所有定義。例如,你的輸出有什麼不好?

  • 眼睛的形狀?
  • 最終渲染(顏色,光線等)?

而且我甚至不問你想要的3D模型的定義。在可以切割橫截面的完整3D模型和適用於3D可視化的3D外表面之間,我想你是在談論後者(對於第一種選擇,方法會完全不同)。

關於最終輸出渲染,我可以給出一些關於如何使用紋理映射的指針 ...這些類型的項目非常有用的功能。與第一紋理

簡單的紋理貼圖,我能找到對谷歌可以給你這種結果: triple eye soft

triple eye redder

下面的代碼(請注意,我定義我的領域稍有不同你但是這只是個人的選擇)

%% // generate unit sphere and prepare figure 
[x,y,z] = sphere(); 
hf=figure('Color','w') ; 
axis equal, grid off , axis off , hold on 

%% // Define the main globe coordinate and generate surface 
rMain = 5; 
xm = x*rMain ; 
ym = y*rMain ; 
zm = z*rMain ; 
mainGlobe = surf(xm, ym, zm, 'edgecolor', 'none' ,'FaceAlpha',0.5) ; 

%% // Define the Iris sphere and generate surface 
rIris = 2.5 ; 
cutoff = ceil(size(x,1)/2) ; %// calculated to get a half sphere (better result for later texture mapping) 
xi = x(:,cutoff:end) * rIris ;  
yi = y(:,cutoff:end) * rIris /3 + (rMain-rIris)*1.7 ;  
zi = z(:,cutoff:end) * rIris ; 
irisGlobe = surf(xi, yi, zi , 'edgecolor', 'none'); 

注意的鳶尾,我開始用半球體,然後我將其壓縮到Y方向(並將其翻譯爲將其定位在主球體的外表面上)。這可以更好地渲染紋理映射。

你有兩個表面,現在應用紋理映射可以是非常簡單的任何東西(我會舉一個簡單的例子),相當乏味...取決於所需的結果和你必須使用的圖像。

對於第一個示例,我將使用2個圖像,一個用於眼球,另一個用於虹膜。圖像將在帖子末尾提供。

%% Apply texture mappings 
imgIris = imread('Iris03.jpg') ; %// read Iris texture image 
imgGlobe = imread('globe02.jpg') ; %// read Globe texture image 

%// (optional) mirror globe image to repeat pattern (and increase definition) 
CDglobe = [imgGlobe flipdim(imgGlobe,2)] ; 

%// apply mapping 
set(mainGlobe,'FaceColor','Texturemap','Cdata',CDglobe,'FaceAlpha',0.5) 
set(irisGlobe,'FaceColor','Texturemap','Cdata',imgIris,'edgecolor', 'none') 

%// texture mapping in default direction produce blood vessel in `Z` 
%// direction mainly, so to have them departing from the Iris, we just 
%// rotate the main globe by 90 degree (or we could also rotate the 
%// image beforehand ...) 
rotate(mainGlobe,[1 0 0],-90) 

由於具有相同的形狀(表面),但紋理不同,所以可以獲得相當不同的結果。例如:

imgIris = imread('Iris01.jpg') ; %// read Iris texture image 
imgGlobe = imread('globe01.jpg') ; %// read Globe texture image 

%// mirror globe image to repeat pattern (and increase definition) 
nrep = 3 ; 
CDglobe = repmat([imgGlobe flipdim(imgGlobe,2)], [1 nrep 1]) ; 

%// apply mapping 
set(mainGlobe,'FaceColor','Texturemap','Cdata',CDglobe,'FaceAlpha',0.5) 
set(irisGlobe,'FaceColor','Texturemap','Cdata',imgIris,'edgecolor', 'none') 

將爲您帶來上述第二組眼圖示例。注意我是如何在應用它們之前複製紋理數據的,它允許在眼睛周圍重複圖案,而不是隻有一次。您可以使用nrep重複因子來獲得不同的結果。


如果你想要一個更凸出的光圈,您可以使用其中yi定義線的變化(這就是球被壓縮和offseted)。例如,具有另一質感和這一行:

yi = y(:,cutoff:end) * rIris + (rMain-rIris)*1.7 - 1.1 ; 

所得鳶尾稍微突出:

enter image description here


用於紋理的圖像被這裏給出。在互聯網上有一個gazillion圖像可以提供更好的結果。無論是合成圖像(純計算機圖形)或真實之眼/虹膜圖像,只是要注意,許多圖像可能具有版權,你將不得不尊重......

+0

哇,你的答案真棒,這是我需要的,再次感謝 –

+0

沒問題。樂意效勞。如果你想幫助這個問題對未來的讀者更有用,你可以稍微改寫一下你的問題(包括標題)以更好地解釋你以後的想法。可能會出現一些不同的(可能更好)答案。如果您滿意,也可以選擇其中一個答案(答案下的_green刻度標記)以向其他讀者表明它回答了您的問題。 – Hoki

0

你要這樣呢?

Someone's Eye

[x, y, z] = sphere(); 
r = 5; 
eballcolor = ones([size(x) 3]); 
surf(r*x, r*y, r*z+2, eballcolor, 'edgecolor', 'none'); 
hold on; 
[x, y, z] = sphere(); 
x = x(15:end,:); 
y = y(15:end,:); 
z = z(15:end,:); 
rx = 4; ry = 4; rz = 8; 
corneacolor = zeros([size(x) 3]); 
surf(rx*x, ry*y, rz*z, corneacolor); 
grid off 
axis off 
axis equal; 
axis vis3d; 

set(gcf, 'Renderer', 'OpenGL'); 
shading interp, material shiny, lighting phong, lightangle(0, 55);