diff --git a/src/Change.java b/src/Change.java index be5054d..49b038b 100644 --- a/src/Change.java +++ b/src/Change.java @@ -13,21 +13,19 @@ public class Change { Util util = new Util(); ArrayList images; + private double magnitude; protected double increments; protected int lastListNum, startListNum; protected int totalImages; // Initializing change data - public Change(ArrayList imgs, int sln, int pln) { + public Change(ArrayList imgs, int sln, int pln, double mag) { images = imgs; startListNum = sln; lastListNum = pln; totalImages = (lastListNum - startListNum) + 1; - } - - // Gets start image of change sequence - public int getStartListNum() { - return startListNum; + magnitude = mag; + increments = magnitude / totalImages; } // Gets last image before change @@ -35,25 +33,6 @@ public int getLastListNum() { return lastListNum; } - // Gets number of images within this change sequence - public int getTotalImages() { - return totalImages; - } - - // Gets the increments dispersed among all images in change sequence - public double getIncrements() { - return increments; - } - - // Sets start image of change sequence - public void setStartListNum(int sln) { - startListNum = sln; - } - - public void setPrevListNum(int pln) { - lastListNum = pln; - } - // Updates xmp file (settings) of all images within change sequence public void updateMetadata(String key) { // Gets start value of change @@ -84,4 +63,23 @@ else if(key.equals("Temperature")) { util.writeFile(currImg, newData); } } + + // Finds an image name from its list number + private String NumToName(int num) { + for (int i = 0; i < images.size(); i++) { + if (i == num) { + return images.get(i).getName(); + } + } + return null; + } + + // Returns a string representation of a Change for human readability. + public String toString() { + return NumToName(startListNum) + " - " + NumToName(lastListNum) + + " (" + startListNum + " - " + lastListNum + ")" + + " [" + totalImages + " images]\n" + + "(" + magnitude + ")" + + " [" + increments + "]"; + } } diff --git a/src/ExposureChange.java b/src/ExposureChange.java deleted file mode 100644 index 91c360e..0000000 --- a/src/ExposureChange.java +++ /dev/null @@ -1,37 +0,0 @@ -import java.util.ArrayList; - -/* This class inherits Change to store data of images when an - * exposure change is detected between images. This class adds - * exposure data to the Change class. - * - * by Devon Crawford - */ - -public class ExposureChange extends Change { - - private double expoChange; - - // Initializes change data - public ExposureChange(ArrayList imgs, int sln, int pln) { - super(imgs, sln, pln); - - increments = expoChange / totalImages; - } - - // Gets exposure change data - public double getExpoChange() { - return expoChange; - } - - // Sets the exposure change data - public void setExpoChange(double rc) { - expoChange = rc; - increments = expoChange / totalImages; - } - - // Sets increments across all images in change - public void setIncrements() { - increments = expoChange/totalImages; - } - -} diff --git a/src/TemperatureChange.java b/src/TemperatureChange.java deleted file mode 100644 index 020455e..0000000 --- a/src/TemperatureChange.java +++ /dev/null @@ -1,30 +0,0 @@ -import java.util.ArrayList; - -/* This class inherits Change to store data when a temperature (color) - * change is detected between images. This class adds temperature data - * to the Change class. - * - * by Devon Crawford - */ - -public class TemperatureChange extends Change { - private int tempChange; - - // Initializes change data - public TemperatureChange(ArrayList imgs, int sln, int pln) { - super(imgs, sln, pln); - increments = tempChange / totalImages; - } - - // Gets temperature change data - public int getTemperatureChange() { - return tempChange; - } - - // Sets temperature change data - public void setTemperatureChange(int tc) { - tempChange = tc; - increments = tempChange / totalImages; - } - -} diff --git a/src/proRAW.java b/src/proRAW.java index 0a688ff..102b018 100644 --- a/src/proRAW.java +++ b/src/proRAW.java @@ -15,8 +15,8 @@ public class proRAW { Util util; ArrayList images; - ArrayList exposureChanges; - ArrayList temperatureChanges; + ArrayList exposureChanges; + ArrayList temperatureChanges; double exposureIncrements; int startLocation, endLocation; @@ -24,8 +24,8 @@ public class proRAW { public proRAW() { util = new Util(); images = new ArrayList(); - exposureChanges = new ArrayList(); - temperatureChanges = new ArrayList(); + exposureChanges = new ArrayList(); + temperatureChanges = new ArrayList(); // Outputs welcome text welcome(); @@ -207,44 +207,16 @@ public void analyzeExposure() { // If the exposure is changed between current and next image if (isExposureChanged(currImg)) { - - ExposureChange newChange = new ExposureChange(images, startExpoChange, i); - double exposure = 0; - - // If the shutter speed was changed - if (currImg.getShutterSpeed() != nextImg.getShutterSpeed()) { - // Use log and doubling function to calculate stops - if (nextImg.getShutterNum() > currImg.getShutterNum()) { - exposure += (Math.log(nextImg.getShutterNum() / currImg.getShutterNum())) / (Math.log(2)); - } else { - exposure -= (Math.log(currImg.getShutterNum() / nextImg.getShutterNum())) / (Math.log(2)); - } - } - - // If the aperture was changed - if (currImg.getAperture() != nextImg.getAperture()) { - // Use log function to calculate stops - exposure += (Math.log(currImg.getAperture() / nextImg.getAperture())) / (Math.log(Math.sqrt(2))); - } - - // If iso was changed - if (currImg.getISO() != nextImg.getISO()) { - // Use log function to calculate stops - if (nextImg.getISO() > currImg.getISO()) { - exposure += (Math.log(nextImg.getISO() / currImg.getISO())) / (Math.log(2)); - } else { - exposure -= (Math.log(currImg.getISO() / nextImg.getISO())) / (Math.log(2)); - } - } - - // If the exposure setting in Photoshop is changed.. - if (currImg.getExposureOffset() != nextImg.getExposureOffset()) { - exposure += (nextImg.getExposureOffset() - currImg.getExposureOffset()); - } - - // Set calculated change to object - newChange.setExpoChange(exposure); - + // We set the exposure change accounting for shutter speed, aperture, ISO and the setting + // change in Photoshop/Lightroom. + Change newChange = new Change( + images, + startExpoChange, + i, + (Math.log(nextImg.getShutterNum() / currImg.getShutterNum())) / (Math.log(2)) + + (Math.log(currImg.getAperture() / nextImg.getAperture())) / (Math.log(Math.sqrt(2))) + + (Math.log(nextImg.getISO() / currImg.getISO())) / (Math.log(2)) + + (nextImg.getExposureOffset() - currImg.getExposureOffset())); // Save exposure change to exposureChanges list! // Allowing multiple exposure changes to occur and be analyzed independently exposureChanges.add(newChange); @@ -275,9 +247,12 @@ public void analyzeWB() { // If white balance is changed if (isWhiteBalanceChanged(currImg)) { // Create new temperature change, calculate difference, and set change - TemperatureChange tempChange = new TemperatureChange(images, startWBChange, i); - tempChange.setTemperatureChange(nextImg.getWhiteBalance() - currImg.getWhiteBalance()); - + Change tempChange = new Change( + images, + startWBChange, + i, + nextImg.getWhiteBalance() - currImg.getWhiteBalance() + ); // Add temperature change to "temperatureChanges" list temperatureChanges.add(tempChange); } @@ -322,26 +297,16 @@ public void updateMetadata() { // Prints all change information from all images public void printChanges() { for (int i = 0; i < exposureChanges.size(); i++) { + Change change = exposureChanges.get(i); System.out.println("======== EXPOSURE CHANGE " + i + " ========"); - System.out.print(NumToName(exposureChanges.get(i).getStartListNum()) + " - " - + NumToName(exposureChanges.get(i).getLastListNum())); - System.out.print(" (" + exposureChanges.get(i).getStartListNum() + " - " - + exposureChanges.get(i).getLastListNum() + ")"); - System.out.println(" [" + exposureChanges.get(i).getTotalImages() + " images]"); - System.out.print("(" + exposureChanges.get(i).getExpoChange() + ")"); - System.out.println(" [" + exposureChanges.get(i).getIncrements() + "]"); + System.out.println(change.toString()); } System.out.println(); for (int i = 0; i < temperatureChanges.size(); i++) { + Change change = temperatureChanges.get(i); System.out.println("======== WHITE BALANCE CHANGE " + i + " ========"); - System.out.print(NumToName(temperatureChanges.get(i).getStartListNum()) + " - " - + NumToName(temperatureChanges.get(i).getLastListNum())); - System.out.print(" (" + temperatureChanges.get(i).getStartListNum() + " - " - + temperatureChanges.get(i).getLastListNum() + ")"); - System.out.println(" [" + temperatureChanges.get(i).getTotalImages() + " images]"); - System.out.print("(" + temperatureChanges.get(i).getTemperatureChange() + ")"); - System.out.println(" [" + temperatureChanges.get(i).getIncrements() + "]"); + System.out.println(change.toString()); } } @@ -373,16 +338,6 @@ public void noImgErr(File img) { System.out.println("Error: \"" + img.getAbsolutePath() + "\" does not exist."); } - // Finds an image name from its list number - public String NumToName(int num) { - for (int i = 0; i < images.size(); i++) { - if (i == num) { - return images.get(i).getName(); - } - } - return null; - } - public static void main(String[] args) { new proRAW(); }