IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Scilab Discussion :

Comment représenter une image (en niveau de gris) en 3D ?


Sujet :

Scilab

  1. #1
    Futur Membre du Club
    Femme Profil pro
    Urbaniste
    Inscrit en
    Novembre 2014
    Messages
    5
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 36
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Urbaniste
    Secteur : Distribution

    Informations forums :
    Inscription : Novembre 2014
    Messages : 5
    Points : 7
    Points
    7
    Par défaut Comment représenter une image (en niveau de gris) en 3D ?
    Bonjour,

    Comment représenter une image (en niveau de gris) en 3D sur scilab ?
    Si par exemple on souhaite voir en « relief » la célèbre image de Lena (voir image) ?

    J'ai trouvé ce code sur Internet (Display a grayscale image in 3D) mais il n'a pas l'air d'être compatible avec Scilab :-(

    Code MATLAB : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    function out = image_3D(img)
    I = imread(img);          % store the data into a matrix I
    m = size(I,1);            % number of rows
    n = size(I,2);            % number of columns
    I = double(I);            % convert the entries to double
    minI = min(min(I));       % min of all the data
    maxI = max(max(I));       % max of all the data
     
    % we create a grid of the same size
    x = 1 : 1 : m; 
    y = 1 : 1 : n; 
    [X,Y] = meshgrid(x,y);
     
    f=figure('Visible','on');       % turn 'off' to disable display
    s2 = subplot(1,2,2,'position',[0.5 0 0.7 0.7]);
    set(s2,'Units','normalized');
    hold on;
    surf(X,Y,I,'LineStyle','none'); % the 3D view of the grayscale image
    colormap(jet);                  % you can change the colormap
    caxis([minI,maxI]);             % to use the complete range of colormap
    colorbar;                       % add a colorbar
    imgzposition = 2*minI-maxI;     % position of the 2D view under the 3D view
     
    % scale the between [0, 255] in order to use a custom color map for it.
    scaledimg = (floor(((I - minI)./(maxI - minI))*255)); % perform scaling
     
    % convert the image to a true color image with the gray colormap.
    colorimg = ind2rgb(scaledimg,gray(256));
     
    % plot the image plane using surf.
    surf([1 m],[1 n],repmat(imgzposition, [2 2]),...
        colorimg,'facecolor','texture');
    set(s2,'YDir','reverse');
    view(45,30);
    xlabel('x');
    ylabel('y');
    zlabel('z');
    title('3D view of the grayscale image');
     
    % We put aside the input grayscale image
    s1 = subplot(1,2,1,'position',[0 0.1 0.4 0.5]);
    set(s1,'Units','normalized');
    imagesc(colorimg);
    xlabel('x');
    ylabel('y');
    title('the input grayscale image');
    %truesize;
     
    set(f, 'Color', 'w');
    f = tightfig(f);
    [pathstr,name,ext] = fileparts(img); % to separate name and extension
    saveas(f,strcat(name,'.pdf'));
    % export_fig does not work because we use a RGB data
    end

    Merci beaucoup !
    Celui qui trouvera une solution sera mon sauveur
    Images attachées Images attachées  

Discussions similaires

  1. Conversion d'une image en niveau de gris
    Par bouki' dans le forum Débuter
    Réponses: 2
    Dernier message: 06/10/2010, 19h39
  2. Réponses: 8
    Dernier message: 05/05/2009, 08h36
  3. Réponses: 1
    Dernier message: 08/03/2007, 15h39
  4. Réponses: 1
    Dernier message: 30/11/2005, 17h12
  5. Réponses: 8
    Dernier message: 17/04/2005, 19h58

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo