The issue I am currently having with my code is it having it randomly display the image I want. I attempted to have a variable named finalImage in which it would be stored once it selected the random image but I cannot have it do so.
Additonally my second issue is how to have the mouse press pickup when I hover over the coordinates of the rectangle I created using rect(); (THIS PART IS LOCATED IN setup() )
 //This gives the button the functionality when hover over
void mousePressed() {
  if (overButton) { 
    link("http://www.processing.org");
  }
}
//Checks whether the mouse is being moved and not being pressed; it allows it to do so.
void mouseMoved() { 
  checkButtons(); 
}
//Checks whether the mouse is moving while being pressed. 
void mouseDragged() {
  checkButtons(); 
}
//This checks whether or not the mouse is being hovered upon. 
void checkButtons() {
  if (mouseX > 75 && mouseX < 230 && mouseY > 50 && mouseY < 50) {
    overButton = true;   
  } else {
    overButton = false;
  }
} //master variables  
PImage[] randomIMG = new PImage[5];
int numOfIMG;
int rand = 0;
PImage image1,image2,image3,image4,image5 , myChosenImage, finalImage;
float height = 100;
float width = 50;
float length = 150;
boolean overButton = false;
void setup() {
  
  size(400,400);
  
  randomIMG[0] = loadImage("image1.jpg");
  randomIMG[1] = loadImage("image2.jpg");
  randomIMG[2] = loadImage("image3.jpg");
  randomIMG[3] = loadImage("image4.jpg"); 
  randomIMG[4] = loadImage("image5.jpg");
  myChosenImage = loadImage("image5.jpg");
 
 int randomIndex = (int) random(5);
 PImage myChosenImage = randomIMG[randomIndex];
 myChosenImage.resize(100,125);
 println("a= " + randomIndex );
 myChosenImage = finalImage;
 
}
 
 
 void draw() { 
   
   //Adding Button Functionality 
   if (overButton == true) {
    fill(255);
  } else {
    noFill();
  }
  //This gives the button a distinct color if clicked. 
  
  background(0);
  fill(150);
  rect(75,50,height, width);
  rect(230,50,height, width);
  myChosenImage.resize(100,125);
  image(myChosenImage,155,145);
 }
//This gives the button the functionality when hover over
void mousePressed() {
  if (overButton) { 
    link("http://www.processing.org");
  }
}
//Checks whether the mouse is being moved and not being pressed; it allows it to do so.
void mouseMoved() { 
  checkButtons(); 
}
//Checks whether the mouse is moving while being pressed. 
void mouseDragged() {
  checkButtons(); 
}
//This checks whether or not the mouse is being hovered upon. 
void checkButtons() {
  if (mouseX > 75 && mouseX < 230 && mouseY > 50 && mouseY < 50) {
    overButton = true;   
  } else {
    overButton = false;
  }
}