# Height Map photos

**URL:** <https://discourse.processing.org/t/height-map-photos/28124>\
**Category:** Gallery\
**Created:** [February 28, 2021, 12:07am UTC](https://discourse.processing.org/t/height-map-photos/28124 "2021-02-28T00:07:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [February 28, 2021, 12:07am UTC](https://discourse.processing.org/t/height-map-photos/28124/1 "2021-02-28T00:07:20Z")

</div>

```auto
import processing.opengl.*;

PImage img;
ArrayList points = new ArrayList();

float rotationY = 0;
float rotationX = 0;
float hgt=0;

void setup()
{
  //size (800,800,OPENGL);
  size (800,800,P3D);
  colorMode(HSB,100);
  background(0);
  smooth();
  
  img=loadImage("vv.png");
  img.loadPixels();
  println(img.width+" "+img.height);
  
  for (int x = 0 ; x<img.width ; x+=2)
  {
    for (int y = 0 ; y<img.height ; y+=2)
    {
      float xx=x-img.width/2;
      float yy=y-img.height/2;
      float zz = 3*brightness(img.get(x,y));
      points.add(new PVector(xx,yy,zz));
    }
  }
  
  
}

void draw()
{
  background(0);
  translate(width/2,height/2);
  image(img,width/4,height/4,width/4,height/4);  

  rotateY(rotationY);
  rotateX(rotationX);

  for (int i = 0 ; i<points.size() ; i++)
  {

    PVector p = (PVector) points.get(i);
    stroke(p.z/3);
    point(p.x,p.y,p.z*cos(hgt));

  }

  hgt+=.01;
  if(hgt>PI/2) hgt=-PI/2;

}

void mouseDragged()
{
  rotationY+= map(mouseX-pmouseX,0,100,0,2);
  rotationX+= map(mouseY-pmouseY,0,100,0,2);
  
}

void keyPressed()
{
  if (key=='1')
  {
    clear();
    
    img=loadImage("clouds.jpg");
    
    println(img.width+" "+img.height);
  
    for (int x = 0 ; x<img.width ; x+=2)
    {
      for (int y = 0 ; y<img.height ; y+=2)
      {
        float xx=x-img.width/2;
        float yy=y-img.height/2;
        float zz = 3*brightness(img.get(x,y));
        points.add(new PVector(xx,yy,zz));
      }
    }
  }
  
  if (key=='2')
  {
    clear();
    
    img=loadImage("bars.jpg");
    
    println(img.width+" "+img.height);
  
    for (int x = 0 ; x<img.width ; x+=2)
    {
      for (int y = 0 ; y<img.height ; y+=2)
      {
        float xx=x-img.width/2;
        float yy=y-img.height/2;
        float zz = 3*brightness(img.get(x,y));
        points.add(new PVector(xx,yy,zz));
      }
    }
  }
  
  if (key=='3')
  {
    clear();
    
    img=loadImage("fibers.jpg");
    
    println(img.width+" "+img.height);
  
    for (int x = 0 ; x<img.width ; x+=2)
    {
      for (int y = 0 ; y<img.height ; y+=2)
      {
        float xx=x-img.width/2;
        float yy=y-img.height/2;
        float zz = 3*brightness(img.get(x,y));
        points.add(new PVector(xx,yy,zz));
      }
    }
  }
  
  if (key=='4')
  {
    clear();
    
    img=loadImage("frames.jpg");
    
    println(img.width+" "+img.height);
  
    for (int x = 0 ; x<img.width ; x+=2)
    {
      for (int y = 0 ; y<img.height ; y+=2)
      {
        float xx=x-img.width/2;
        float yy=y-img.height/2;
        float zz = 3*brightness(img.get(x,y));
        points.add(new PVector(xx,yy,zz));
      }
    }
  }
  
  if (key=='5')
  {
    clear();
    
    img=loadImage("zebra.jpg");
    
    println(img.width+" "+img.height);
  
    for (int x = 0 ; x<img.width ; x+=2)
    {
      for (int y = 0 ; y<img.height ; y+=2)
      {
        float xx=x-img.width/2;
        float yy=y-img.height/2;
        float zz = 3*brightness(img.get(x,y));
        points.add(new PVector(xx,yy,zz));
      }
    }
  }
  
  if (key=='6')
  {
    clear();
    
    img=loadImage("zebra smooth.jpg");
    
    println(img.width+" "+img.height);
  
    for (int x = 0 ; x<img.width ; x+=2)
    {
      for (int y = 0 ; y<img.height ; y+=2)
      {
        float xx=x-img.width/2;
        float yy=y-img.height/2;
        float zz = 3*brightness(img.get(x,y));
        points.add(new PVector(xx,yy,zz));
      }
    }
  }
}

void clear()
{
  for (int i = points.size() - 1 ; i >= 0 ; i--)
  {
    points.remove(i);
  }
  println(points.size());
}

```

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [February 28, 2021, 12:08am UTC](https://discourse.processing.org/t/height-map-photos/28124/2 "2021-02-28T00:08:35Z")

</div>

![Untitled 39](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/b/b0664e9154caab1750ef42f5a977cc0c0c790f94.jpeg)

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [February 28, 2021, 12:09am UTC](https://discourse.processing.org/t/height-map-photos/28124/3 "2021-02-28T00:09:41Z")

</div>

![Untitled 40](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/8/8936a69bab6473349811ae6d95a997274ec0f5b1.jpeg)
