Archive pour 11 juillet 2008

quelques codes pour matlab et courbes 2D 3D image

xes abscisses d’un graphique ?

Les objets de type Axes ne possèdent pas de propriété permettant d’incliner les labels des repères de l’axe des abscisses d’un graphique.

Il existe néanmoins plusieurs contributions disponibles sur le File EXchange qui répondent à ce besoin :

—————

Comment mettre une étiquette à mes points ?

x=rand(3,1);
y=rand(3,1);

figure
plot(x,y,'r+');

str=num2str([1:numel(x)].','%1d'); % ATTENTION le premier argument de NUM2STR doit être un vecteur colonne
text(x+0.01,y+0.01,str) % Le décalage de 0.01 est arbitraire ici.
------------
omment tracer une ligne dont la couleur varie ?
x = rand(3,1);
y = rand(3,1);

figure
subplot(2,1,1)
plot(x,y)

subplot(2,1,2)

patch('xdata',[x;x(end:-1:1)],...
      'ydata',[y;y(end:-1:1)],...
      'facecolor','interp', ...
      'edgecolor','interp',...
      'facevertexcdata',[y;y(end:-1:1)])
-------------
omment animer le tracé d'une courbe ?
% Génération des données
th=0:0.02:10*pi;
y=sin(th);

% Création de l'objet Figure contenant les tracés
fig=figure;

% Première objet Axes  est tracée la courbe directe
subplot(2,1,1)
% Tracé de la courbe
plot(th,y,'r-')
% Ajustement des limites de l'objet Axes
xlim([min(th) max(th)])
ylim([min(y) max(y)])

% Second objet Axes  est tracée la courbe animée
subplot(2,1,2)

% Modification de la propriété DoubleBuffer de l'objet Figure pour
% éviter le clignotement de la fenêtre
% NECESSAIRE POUR TOUTE ANIMATION
set(fig,'doublebuffer','on')

% Tracé du premier point de la courbe
% et récupération de l'identifiant (handle) p de l'objet Line crée.
p=plot(th(1),y(1),'r-');
% Ajustement des limites de l'objet Axes
xlim([min(th) max(th)])
ylim([min(y) max(y)])

% On boucle sur le nombre de points à tracer. 
% On démarre à 2 puisque le premier est déjà tracé
for n=2:numel(th)

  % Ajout des points de la courbe au fur et à mesure
  % en utilisant la combinaison SET + identifiant (handle)
  set(p,'xdata',th(1:n),'ydata',y(1:n));
  % Forçage de l'affichage du tracé
  drawnow

end
-------------
Comment récupérer les valeurs de données tracées ?
Dans tous les cas, il faut utiliser la fonction FINDOBJ pour récupérer l'identifiant de l'objet dont on veut
		récupérer les données.

Pour les objets de type Line (nuage de points ou lignes), Surface ou Mesh, on récupère les propriétés XDATA, YDATA et ZDATA

Pour les objets de type Image, on récupère la propriété CDATA

Pour les objets de type Patch, on récupère, soit les propriétés XDATA, YDATA et ZDATA, soit les propriétés VERTICES et FACES


[X,Y,Z] = peaks(20)
surf(X,Y,Z);

h=findobj('type','surf');
xx=get(h,'xdata')
yy=get(h,'ydata')

zz=get(h,'zdata')
--------------------
Comment redimensionner une image ?
La première solution consiste à utiliser la fonction IMRESIZE contenue dans l'Image Processing Toolbox.

La deuxième solution utilise l'indexage des matrices. Puisqu'une
image est une matrice 2D ou 3D (RGB), il est très simple de diminuer la
taille d'une image en jouant sur l'indexage. Par exemple, pour diminuer
par deux la taille d'une image 2D, il suffit de ne conserver qu'un pixel sur deux


img=rand(150,200); % Une image 2D aléatoire
size(img)

ans =

   150   200

img=img(1:2:end,1:2:end);

size(img)

ans =

    75   100

--------Pour une image 3D (RGB), le code devient :
img=rand(150,200,3); % Une image 3D (RGB) aléatoire
size(img)

ans =

   150   200     3

img=img(1:2:end,1:2:end,:);

size(img)

ans =

    75   100     3
-----
On remarque que cette solution utilisant l'indexage se limite à des facteurs de réductions/agrandissement entier.

La troisième solution utilise les fonctions d'interpolation.

Soit INTERP2 pour diminuer par deux la taille d'une image 2D :
img = rand(150,200); % Une image 2D aléatoire
size(img)

ans =

   150   200

[c,r ] = size(img); % Récupération des 2 dimensions de l'image

[ci,ri] = meshgrid(1:2:r,1:2:c); % Génération de la grille d'interpolation

img = interp2(img,ci,ri); % Interpolation des valeurs des pixels

size(img)

ans =

    75   100

Soit INTERP3 pour diminuer par deux la taille d'une image 3D :
img = rand(150,200,3); % Une image 3D (RGB) aléatoire
 size(img)

ans =

   150   200     3

[c,r,p] = size(img); % Récupération des 3 dimensions de l'image

[ci,ri,pi] = meshgrid(1:2:r,1:2:c,1:p); % Génération de la grille d'interpolation

img = interp3(img,ci,ri,pi); % Interpolation des valeurs des pixels du plan R

size(img)

 ans =

ans =

    75   100     3

VRML of a segmented image

I have an image segmented in matlab (in the form of 3d matrix with
elements 0 and 1) and from that matrix I want to create a vrml model,
do you know the best way to do it (with or without matlab, even if
with matlab I have the virtual reality toolbox installed)!

f,v]=isosurface (3Dmatrix,0);
translated to vrml with a simple script:


[fid,errmsg] = fopen(‘mymodel.wrl’,’w+’);

—-

fprintf(fid,’ coord Coordinate {\n’);
fprintf(fid,’ point [\n’);

for i=1:size (v,1)
fprintf(fid,’%f ‘,v(i,1)/500);
fprintf(fid,’%f ‘,v(i,2)/500);
fprintf(fid,’%f ‘,v(i,3)/500);
fprintf(fid,’\n’);
end

fprintf(fid,’ ]#Point\n’);
fprintf(fid,’ }#Coordinate\n’);
fprintf(fid,’ index[\n’);

for i=1:size (f,1)
fprintf(fid,’%d ‘,f(i,1)-1);
fprintf(fid,’%d ‘,f(i,2)-1);
fprintf(fid,’%d ‘,f(i,3)-1);
fprintf(fid,’\n’);
end

fprintf(fid,’ ]#index\n’);

fclose (fid);

Will you please show some (first ten lines – max .1kB) of the result?

unfortunately 30 megabytes for a 218x218x128 image!

The wrl file is not an image, it is the geometry and lighting.
You are sending the browser (the program that runs the .wrl file

(sets of x,y,z vertex values along with the info to make them
into triangles and lights that become pixels.

http://www.web3d.org/x3d/specifications/ISO-IEC-19776-X3DEncodings-XML-ClassicVRML/

that’s too much (for both speed and memory), even because i want to
deal with much bigger matrix!

Great, we all want that.

ref: http://newsgroups.derkeiler.com/Archive/Comp/comp.lang.vrml/2007-08/msg00007.html

blender file format data

Here are links to file format specs or implementations, with particlar focus on those useful in DCC (Digital Content Creation); CAD (Computer Assisted Design); video/web animation/3d Display formats; game content formats; 2d image formats; and lastly sound formats

The most widely supported CAD formats are DXF, DWG, IGES and STEP

The most widely supported DCC formats are OBJ, LWO, 3DS, Collada

The most widely supported web 3d content formats are Shockwave, VRML, X3D, U3D

The most widely supported image formats are Adobe Photoshop, PNG, JPG, GIF

if (window.showTocToggle) { var tocShowText = « show »; var tocHideText = « hide »; showTocToggle(); }

CAD formats

DCC file formats

  • FBX API – there is not a format spec available that I can find only specs for the library/api:

WEB file formats

Motion Capture Formats

http://gl.ict.usc.edu/animWeb/humanoid/fileFormats.html

Image Formats

Vector Image Formats

Scene Description Languages

Lectures on Scene Description languages http://www.cs.utah.edu/classes/cs6620/lecture-2005-01-28-6up.pdf http://www.cs.utah.edu/classes/cs6620/lecture-2005-01-28.pdf

PPM Format Specification http://netpbm.sourceforge.net/doc/ppm.html

Neutral File Format http://www.acm.org/pubs/tog/resources/SPD/NFF.TXT

Polygon File Format http://astronomy.swin.edu.au/%7Epbourke/geomformats/ply/

PLY Tools http://www.cc.gatech.edu/projects/large_models/ply.html

Scene Description languages
RenderMan Interface Specification https://renderman.pixar.com/products/rispec/

Radiance Scene Description language http://radsite.lbl.gov/radiance/refer/Notes/language_BNR.html

Manchester Scene Description language http://astronomy.swin.edu.au/~pbourke/dataformats/msdl/

POVRAY scene description language http://www.lobos.nih.gov/Charmm/Povray3/pov30019.html

YAFRAY scene description language (is there an official version somewhere??) http://download.blender.org/documentation/htmlI/ch30s03.html
Another list of format links (most of the links are broken) http://www.agocg.ac.uk/reports/virtual/36/appendix.htm

Universal translator tools

  • Polytrans – universal 3d format converter – very useful table of what formats are supported by different CAD programs, also explains the strengths and limitations of different formats http://www.okino.com/conv/filefrmt.htm

Misc lists of formats and universal importers/exporters

  • An extremely large list of formats and specs some with sample code

(note that for some of the formats he links there are much more complete specs availabled – ie lightwave lwo) http://astronomy.swin.edu.au/~pbourke/dataformats/

  • Material Exchange Format (a subset of the Advanced Authoring Format):

http://www.ebu.ch/trev_291-devlin.pdf

Useful overview of MEF http://www.digitalpreservation.gov/formats/fdd/fdd000013.shtml

HOOPS Streaming File Format spec – http://www.openhsf.org/specification/index.html

Imagine IOB – code to parse it http://www.pygott.demon.co.uk/prog.htm

Misc stuff

Poser related format data

Cell3D

http://www.3d-node.com/cmsimple-en/?Products%2C_Projects%26nbsp%3Band_Services:Cell3D

Introduction

Interactive 3D-Visualization of various microscopic image stacks.

First version was implemented in pure MS-Visual-c++ and OpenGl. The new version uses the MedWorld3D-VRML/X3D-Core. It supports all the (interactive) features of MedWorld3D and some new components especially for microscopic visualization.

Image import features (additionally to DICOM, ACR-NEMA): JPG, BMP, RAW, TIFF, PNG, JPEG2000, Biorad, Metamorph, Zeiss, Lucia, Nikon, Leica, Autooquant, Imagepro

Preparation features (additionally to MedWorld3D-features): innovative script mechanism for different filters and filter combinations for multiple ROIs.

Postprocessing features (additionally to MedWorld3D-features): 3D-Color-Manipulation, interactive chromatek 3D, object code combination

Project Status: Version 1.5 finished.

Images

Download

Interactive anatomical 3d-visualisation powered by X3D/VRML

Interactive 3D Visualization technique represents an important diagnosis and therapy planning tool. It cannot be compensated with simple 2D Pictures or static 3D Views.

Multimedia teaching tools which contain textual information, non-interactive videos and restricted pseudo three-dimensional scenarios can considerably contribute to the understanding of medical facts by the completion of interactive 3D Components. Multiuser environments are also an important aspect to recognize coherence of single events in patients physical health and to support medical teachings.

Until now, these techniques are not applicable every time and everywhere. Insufficient software functionality and quality, competitive and proprietary software and hardware as well as different system requirements for visualization aggravated the distribution of interactive 3D Systems.

So far, there is no common standard for 3D Geometry in medicine, like the Dicom files. These files include medical 2D Images, patient information and acquisition details in a special syntax.

Besides many simple 3D File formats, there are also considerably « more intelligent » specifications, like the XML compliant X3D specification. The new system reduces or eliminates all disadvantages of the regular systems and opens new Potentials.

http://www.3d-node.com/cmsimple-en/?Products%2C_Projects%26nbsp%3Band_Services:MedWorld3D

——–

Features (public Version 1.0.0)

  • 3D-Generator reads and creates 3d data from DICOM, JPG, BMP, RAW
  • VRML97/X3D compliant, tested with viper (vrml) and most known plugins on different OSs (vrml,x3d)
  • Platform-independent, uses a standard Browser Plugin (Best viewed with Cortona,BS-Contact,Freewrl or GLView, because of missing/bad/buggy script-implementation in octagonfree,flux,openvrml,venues,horizon,casa,vrweb – on those browsers only limited features)
  • Works with PocketCortona on Pdas
  • Ergonomic x3d/vrml interface, also for full windowxp-tabletpc use
  • 3D-manipulation functions like 3d-volume/area measuring and 3d-annotations in X3D/VRML. Transformation of 2D markers into 3d space and back. Export to ISO-SVG-Code.
  • Access to the real world via java-servlets
  • Multiprocessing, multimonitor and multiuser realtime experience trough EAI and SAI, limited only by the java-socket-interface and EAI availability (IE)
  • Multiuser database control for the 3d-manipulation system via java-servlets
  • Dicom-source-browsing via java-servlets (on next version also texture mapping)
  • Easy StepIn3D-system for vrml/x3d-beginners (plugin installation, tips, os-control)
  • Anatomical X3D/VRML-data-generation for all greyscale-datasets like CT,MR in dicoms/jpg/bmp-files (volume surface rendering with marching cube), interactive rendering control and annotation support with virtual sound and text enhancement -modular design, pluggable features via the 3d-generator-authoring-tool
  • Export of dicom-tags (patient,physician, institute…) to XML files for integration in X3D-scenes
  • Supports also special devices: X3D/VRML-viewer-software like 4d-vision stereo display software, phantom force-feedback-system, actual-systems holo-viewer (reduced vrml subset)
  • Special stereoscopic support and interface-design on all stereo-enabled devices (nvidia…) with e.g. cortona or glview
  • Hardware support for spaceball and spacemouse over special emulator software for all vrml/x3d viewers (windows only)
  • DirectX-device-support via bs-contact joystick interface and cortona keyboard-interface via plugin-independent joystick-emulator(partially third party, thanks to www.deinmeister.de)
  • Programmable POS-Keyboard support for cortona keyboard-nodes -plugin independent realtime image manipulation in the 2d-gui and 3d-gui(windows only, but next version comes also for linux and mac) –

I MOVED THIS BLOG FROM WORDPRESS TO BLOGGER. Ce blog est à
ex-ample.blogspot.com

Blog Stats

  • 223 372 hits

Meilleurs clics

  • Aucun

localization

Flickr Photos

juillet 2008
L M M J V S D
 123456
78910111213
14151617181920
21222324252627
28293031