Skip to content

Commit

Permalink
Initial Upload
Browse files Browse the repository at this point in the history
  • Loading branch information
asack20 authored May 12, 2017
1 parent 9fef8c7 commit 4684a5d
Show file tree
Hide file tree
Showing 74 changed files with 1,043 additions and 0 deletions.
62 changes: 62 additions & 0 deletions CalculationFunctions/combinedSmooth.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
function [smoothImg, loadNum] = combinedSmooth(img, thresh, M, N, loadNum, totLoad)
%function [smoothImg, loadNum] = combinedSmooth(img, thresh, M, N, loadNum, totLoad)
% Inputs:
% img: matrix of uint8 image data to be corrected
% thresh: the decimal value between 0 and 1 of the minimum median
% difference a pixel must be from its surrounding pixels for
% filtering to occur
% M: x/row size dimension of box surrounding a pixel that is included
% in the median filtering.
% N: y/column sized dimension of box surrounding a pixel that is
% included in the median filtering.
% loadNum: current number of times the waitbar has updated
% totLoad: total number of times waitbar will update
% Output:
% smoothImg: matrix of uint8 corrected image data
% loadNum: updated counter value
%
% Andrew Sack
% Lab LA
% 5/10/17


iDub = im2double(img); % converts uint8 to double
[numRows, numCols, numChan] = size(img);

smoothImg = img;

m = round((M-1)/2);
n = round((N-1)/2);

for curChan = 1:numChan
for row = 1:numRows
for col = 1:numCols
tempDiffs = [];
for curRow = row-m : row+m
for curCol = col-n : col+n
if (curRow >= 1) && (curRow <= numRows) && (curCol >= 1) && (curCol <= numCols)&& (~((curCol == col)&&(curRow == row)))
tempDiffs = [tempDiffs abs(iDub(curRow, curCol, curChan)-iDub(row,col,curChan))];
end
end
end
iMag = median(tempDiffs);
if iMag > thresh
tempVal = [];
for curRow = row-m : row+m
for curCol = col-n : col+n
if (curRow >= 1) && (curRow <= numRows) && (curCol >= 1) && (curCol <= numCols)
tempVal = [tempVal img(curRow, curCol, curChan)];
end
end
end
smoothImg(row, col, curChan) = median(tempVal);
end
end
loadNum = loadNum + 1;
waitbar(loadNum/totLoad);
end
end

smoothImg = uint8(smoothImg);

end
41 changes: 41 additions & 0 deletions CalculationFunctions/distortImg.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
function newImg = distortImg(img, distortPercent)
%function newImg = distortImg(img, distortPercent)
% Inputs:
% img: input image of any number of channels
% distortPercent: Percentage (0-100) # of pixel distortions/# of
% pixels in image (The actual percentage of distorted pixels will be
% lower due to repeated pixels)
% Output:
% newImg: distorted image
%
% Andrew Sack
% Lab LA
% 5/10/17

% This function will randomly select the desired number of pixels and then
% replace their values with random color values across all channels

[rows, columns, ~] = size(img);

distortAmount = distortPercent/100;
pixels = rows * columns;
distortNum = round(pixels * distortAmount); % # of pixels to distort

distortIndex = zeros(distortNum, 2); % matrix of distorted pixel locations


distortIndex(:, 1) = randi(rows, distortNum, 1); % x values of distorted pixels
distortIndex(:, 2) = randi(columns, distortNum, 1); % y values of distorted pixels

distortValue = randi(255, distortNum, 3);% separate matrix of distorted pixel values

newImg = img;

for k = 1:distortNum
newImg(distortIndex(k,1),distortIndex(k,2),:) = distortValue(k, :);
end

newImg = uint8(newImg);

end

47 changes: 47 additions & 0 deletions CalculationFunctions/smoothAll.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
function [smoothImg, loadNum, totLoad] = smoothAll(img, M, N, loadNum, totLoad)
%function [smoothImg, loadNum, totLoad] = smoothAll(img, M, N, loadNum, totLoad)
% Inputs:
% img: matrix of uint8 image data to be corrected
% M: x/row size dimension of box surrounding a pixel that is included
% in the median filtering.
% N: y/column sized dimension of box surrounding a pixel that is
% included in the median filtering.
% loadNum: current number of times the waitbar has updated
% totLoad: total number of times waitbar will update
% Output:
% smoothImg: matrix of uint8 corrected image data
% loadNum: updated counter value
%
% Andrew Sack
% Lab LA
% 5/10/17

iDub = im2double(img); % converts uint8 to double
[numRows, numCols, numChan] = size(img);

smoothImg = img;

m = round((M-1)/2);
n = round((N-1)/2);

for curChan = 1:numChan
for row = 1:numRows
for col = 1:numCols
tempVal = [];
for curRow = row-m : row+m
for curCol = col-n : col+n
if (curRow >= 1) && (curRow <= numRows) && (curCol >= 1) && (curCol <= numCols)
tempVal = [tempVal img(curRow, curCol, curChan)];
end
end
end
smoothImg(row, col, curChan) = median(tempVal);
end
loadNum = loadNum + 1;
waitbar(loadNum/totLoad);
end
end

smoothImg = uint8(smoothImg);

end
Binary file added Data/balloons_noisy.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Data/black.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Data/bw_cubes.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Data/bw_plain.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Data/cake.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Data/lizard_noisy.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Data/monaLisa.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Data/puppy.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Data/purple.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Data/rubixCube.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Data/sunset.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Data/tree.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Data/wheat.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Data/white.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file added Results/ChangeMandN/wheat_M25_N1_nonselective.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions Results/ChangeMandN/wheat_M25_N1_nonselective.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Image Correction Details
------------------------------------------------

Original Image:
---------------
size: 256 x 256 pixels

*image was not distorted*

Image Correction:
-----------------
parameters:
correction method: non-selective
M: 25
N: 1
number of iterations: 1
proccessing time: 7.1 seconds

------------------------------------------------

created: 12-May-2017 14:17:48 -0400
Andrew Sack
Binary file not shown.
Binary file added Results/ChangeMandN/wheat_M3_N15_nonselective.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions Results/ChangeMandN/wheat_M3_N15_nonselective.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Image Correction Details
------------------------------------------------

Original Image:
---------------
size: 256 x 256 pixels

*image was not distorted*

Image Correction:
-----------------
parameters:
correction method: non-selective
M: 3
N: 15
number of iterations: 1
proccessing time: 11.7 seconds

------------------------------------------------

created: 12-May-2017 14:18:30 -0400
Andrew Sack
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions Results/CompareDistortAmounts/puppy_distort100_selective.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Image Correction Details
------------------------------------------------

Original Image:
---------------
size: 270 x 360 pixels

Image Distortion:
-----------------
distortion percent: 100.0%

Image Correction:
-----------------
parameters:
correction method: selective
threshold: 0.10
M: 3
N: 3
number of iterations: 1
proccessing time: 7.4 seconds

------------------------------------------------

created: 12-May-2017 13:59:56 -0400
Andrew Sack
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions Results/CompareDistortAmounts/puppy_distort20_selective.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Image Correction Details
------------------------------------------------

Original Image:
---------------
size: 270 x 360 pixels

Image Distortion:
-----------------
distortion percent: 20.0%

Image Correction:
-----------------
parameters:
correction method: selective
threshold: 0.10
M: 3
N: 3
number of iterations: 1
proccessing time: 5.0 seconds

------------------------------------------------

created: 12-May-2017 13:57:31 -0400
Andrew Sack
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions Results/CompareDistortAmounts/puppy_distort40_selective.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Image Correction Details
------------------------------------------------

Original Image:
---------------
size: 270 x 360 pixels

Image Distortion:
-----------------
distortion percent: 40.0%

Image Correction:
-----------------
parameters:
correction method: selective
threshold: 0.10
M: 3
N: 3
number of iterations: 1
proccessing time: 5.6 seconds

------------------------------------------------

created: 12-May-2017 13:57:03 -0400
Andrew Sack
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions Results/CompareDistortAmounts/puppy_distort60_selective.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Image Correction Details
------------------------------------------------

Original Image:
---------------
size: 270 x 360 pixels

Image Distortion:
-----------------
distortion percent: 60.0%

Image Correction:
-----------------
parameters:
correction method: selective
threshold: 0.10
M: 3
N: 3
number of iterations: 1
proccessing time: 6.5 seconds

------------------------------------------------

created: 12-May-2017 13:59:20 -0400
Andrew Sack
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions Results/CompareDistortAmounts/puppy_distort80_selective.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Image Correction Details
------------------------------------------------

Original Image:
---------------
size: 270 x 360 pixels

Image Distortion:
-----------------
distortion percent: 80.0%

Image Correction:
-----------------
parameters:
correction method: selective
threshold: 0.10
M: 3
N: 3
number of iterations: 1
proccessing time: 6.9 seconds

------------------------------------------------

created: 12-May-2017 13:58:28 -0400
Andrew Sack
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions Results/CompareThresholds/cake_thresh_0point10.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Image Correction Details
------------------------------------------------

Original Image:
---------------
size: 370 x 410 pixels

Image Distortion:
-----------------
distortion percent: 30.0%

Image Correction:
-----------------
parameters:
correction method: selective
threshold: 0.10
M: 3
N: 3
number of iterations: 1
proccessing time: 8.9 seconds

------------------------------------------------

created: 12-May-2017 14:02:14 -0400
Andrew Sack
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions Results/CompareThresholds/cake_thresh_0point50.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Image Correction Details
------------------------------------------------

Original Image:
---------------
size: 370 x 410 pixels

Image Distortion:
-----------------
distortion percent: 30.0%

Image Correction:
-----------------
parameters:
correction method: selective
threshold: 0.50
M: 3
N: 3
number of iterations: 1
proccessing time: 6.6 seconds

------------------------------------------------

created: 12-May-2017 14:04:24 -0400
Andrew Sack
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 4684a5d

Please sign in to comment.