Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
Image Compression
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nathaniel Callens
Image Compression
Commits
5c7cf95e
Commit
5c7cf95e
authored
Feb 05, 2022
by
Kelly Chang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kelly changes
parent
e4df997c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
76 additions
and
90 deletions
+76
-90
multiple_compression_kelly-checkpoint.ipynb
...b_checkpoints/multiple_compression_kelly-checkpoint.ipynb
+18
-27
prediction_MSE_kelly-checkpoint.ipynb
.ipynb_checkpoints/prediction_MSE_kelly-checkpoint.ipynb
+20
-18
multiple_compression_kelly.ipynb
multiple_compression_kelly.ipynb
+18
-27
prediction_MSE_kelly.ipynb
prediction_MSE_kelly.ipynb
+20
-18
No files found.
.ipynb_checkpoints/
compression_jupyter
-checkpoint.ipynb
→
.ipynb_checkpoints/
multiple_compression_kelly
-checkpoint.ipynb
View file @
5c7cf95e
...
...
@@ -213,7 +213,7 @@
},
{
"cell_type": "markdown",
"id": "
d866df6f
",
"id": "
5437bd8d
",
"metadata": {},
"source": [
"## use MSE"
...
...
@@ -221,7 +221,7 @@
},
{
"cell_type": "code",
"execution_count":
42
,
"execution_count":
50
,
"id": "73412bc9",
"metadata": {},
"outputs": [],
...
...
@@ -233,47 +233,38 @@
" fix this later. 1/25/22\n",
" \"\"\"\n",
" \n",
"\n",
" image = tiff_list\n",
" image = Image.open(image) #Open the image and read it as an Image object\n",
" image = np.array(image)[1:,:] #Convert to an array, leaving out the first row because the first row is just housekeeping data\n",
" image = image.astype(int)\n",
" row, col = image.shape\n",
" predict = np.empty([row,col]) # create a empty matrix to update prediction\n",
" predict[0,:] = np.copy(image[0,:]) # keep the first row from the image\n",
" predict[:,0] = np.copy(image[:,0]) # keep the first columen from the image\n",
" predict[-1,:] = np.copy(image[-1,:]) # keep the first row from the image\n",
" predict[:,-1] = np.copy(image[:,-1]) # keep the first columen from the image\n",
" diff = np.empty([row,col])\n",
" diff[0,:] = np.zeros(col) # keep the first row from the image\n",
" diff[:,0] = np.zeros(row)\n",
" diff[-1,:] = np.zeros(col) # keep the first row from the image\n",
" diff[:,-1] = np.zeros(row)\n",
" A = np.array([[3,0,-1],[0,3,3],[1,-3,-4]])\n",
" z0 = image[0:-2,0:-2]\n",
" z1 = image[0:-2,1:-1]\n",
" z2 = image[0:-2,2::]\n",
" z3 = image[1:-1,0:-2]\n",
" A = np.array([[3,0,-1],[0,3,3],[1,-3,-4]]) # the matrix for system of equation\n",
" z0 = image[0:-2,0:-2] # get all the first pixel for the entire image\n",
" z1 = image[0:-2,1:-1] # get all the second pixel for the entire image\n",
" z2 = image[0:-2,2::] # get all the third pixel for the entire image\n",
" z3 = image[1:-1,0:-2] # get all the forth pixel for the entire image\n",
" # calculate the out put of the system of equation\n",
" y0 = np.ravel(-z0+z2-z3)\n",
" y1 = np.ravel(z0+z1+z2)\n",
" y2 = np.ravel(-z0-z1-z2-z3)\n",
" y = np.vstack((y0,y1,y2))\n",
" # use numpy solver to solve the system of equations all at once\n",
" predict = np.linalg.solve(A,y)[-1]\n",
" \n",
"
# flatten the neighbor pixlels and stack them together
\n",
" z0 = np.ravel(z0)\n",
" z1 = np.ravel(z1)\n",
" z2 = np.ravel(z2)\n",
" z3 = np.ravel(z3)\n",
" neighbor = np.vstack((z0,z1,z2,z3)).T\n",
" # calculate the difference\n",
" diff = np.max(neighbor,axis = 1) - np.min(neighbor, axis=1)\n",
" \n",
"
# flatten the image to a vector
\n",
" image = np.ravel(image[1:-1,1:-1])\n",
" return image, predict, diff"
]
},
{
"cell_type": "code",
"execution_count":
44
,
"execution_count":
51
,
"id": "1bc0bed5",
"metadata": {},
"outputs": [],
...
...
@@ -287,8 +278,8 @@
},
{
"cell_type": "code",
"execution_count":
46
,
"id": "
a8c46fb2
",
"execution_count":
52
,
"id": "
0f908e6c
",
"metadata": {},
"outputs": [
{
...
...
@@ -296,7 +287,7 @@
"output_type": "stream",
"text": [
"mean of error = 18.740279058331875\n",
"time to run = 0.0
6311893463134766
\n"
"time to run = 0.0
7091403007507324
\n"
]
},
{
...
...
@@ -330,7 +321,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "
0c73bbe
2",
"id": "
fb798c3
2",
"metadata": {},
"outputs": [],
"source": []
...
...
@@ -338,7 +329,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "
1f19bb5d
",
"id": "
23f8c8a7
",
"metadata": {},
"outputs": [],
"source": []
...
...
.ipynb_checkpoints/prediction_MSE-checkpoint.ipynb
→
.ipynb_checkpoints/prediction_MSE
_kelly
-checkpoint.ipynb
View file @
5c7cf95e
...
...
@@ -19,7 +19,7 @@
},
{
"cell_type": "code",
"execution_count":
2
,
"execution_count":
44
,
"id": "b7a550e0",
"metadata": {},
"outputs": [],
...
...
@@ -74,7 +74,7 @@
},
{
"cell_type": "code",
"execution_count":
4
1,
"execution_count":
5
1,
"id": "9ed20f84",
"metadata": {},
"outputs": [],
...
...
@@ -91,33 +91,35 @@
" image = Image.open(image) #Open the image and read it as an Image object\n",
" image = np.array(image)[1:,:] #Convert to an array, leaving out the first row because the first row is just housekeeping data\n",
" image = image.astype(int)\n",
"
row, col = image.shape
\n",
"
A = np.array([[3,0,-1],[0,3,3],[1,-3,-4]])
\n",
" z
0 = image[0:-2,0:-2]
\n",
" z
1 = image[0:-2,1:-1]
\n",
" z
2 = image[0:-2,2::]
\n",
"
z3 = image[1:-1,0:-2]
\n",
"
A = np.array([[3,0,-1],[0,3,3],[1,-3,-4]]) # the matrix for system of equation
\n",
"
z0 = image[0:-2,0:-2] # get all the first pixel for the entire image
\n",
" z
1 = image[0:-2,1:-1] # get all the second pixel for the entire image
\n",
" z
2 = image[0:-2,2::] # get all the third pixel for the entire image
\n",
" z
3 = image[1:-1,0:-2] # get all the forth pixel for the entire image
\n",
"
# calculate the out put of the system of equation
\n",
" y0 = np.ravel(-z0+z2-z3)\n",
" y1 = np.ravel(z0+z1+z2)\n",
" y2 = np.ravel(-z0-z1-z2-z3)\n",
" y = np.vstack((y0,y1,y2))\n",
"\n",
" predict = np.linalg.solve(A,y
[:10]
)[-1]\n",
" \n",
"
# use numpy solver to solve the system of equations all at once
\n",
" predict = np.linalg.solve(A,y)[-1]\n",
"
# flatten the neighbor pixlels and stack them together
\n",
" z0 = np.ravel(z0)\n",
" z1 = np.ravel(z1)\n",
" z2 = np.ravel(z2)\n",
" z3 = np.ravel(z3)\n",
" neighbor = np.vstack((z0,z1,z2,z3)).T\n",
" diff = np.max(neighbor,axis = 1) - np.max(neighbor, axis=1)\n",
" \n",
" # calculate the difference\n",
" diff = np.max(neighbor,axis = 1) - np.min(neighbor, axis=1)\n",
" # flatten the image to a vector\n",
" image = np.ravel(image[1:-1,1:-1])\n",
" return image, predict, diff"
" return image, predict, diff\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 4
2
,
"execution_count": 4
9
,
"id": "8e3ef654",
"metadata": {},
"outputs": [],
...
...
@@ -150,7 +152,7 @@
},
{
"cell_type": "code",
"execution_count":
43
,
"execution_count":
52
,
"id": "fa65dcd6",
"metadata": {},
"outputs": [
...
...
@@ -160,8 +162,8 @@
"text": [
"Average Error First and Second Added: 20.017164930235474\n",
"Standard Deviaiton of Mean Errors: 0.16101183692475135\n",
"Average Difference:
-
53.678648426455226\n",
"Average Time per Image for First: 0.0
508149564266204
8\n"
"Average Difference: 53.678648426455226\n",
"Average Time per Image for First: 0.0
453574061393737
8\n"
]
}
],
...
...
compression_jupyter
.ipynb
→
multiple_compression_kelly
.ipynb
View file @
5c7cf95e
...
...
@@ -213,7 +213,7 @@
},
{
"cell_type": "markdown",
"id": "
d866df6f
",
"id": "
5437bd8d
",
"metadata": {},
"source": [
"## use MSE"
...
...
@@ -221,7 +221,7 @@
},
{
"cell_type": "code",
"execution_count":
42
,
"execution_count":
50
,
"id": "73412bc9",
"metadata": {},
"outputs": [],
...
...
@@ -233,47 +233,38 @@
" fix this later. 1/25/22\n",
" \"\"\"\n",
" \n",
"\n",
" image = tiff_list\n",
" image = Image.open(image) #Open the image and read it as an Image object\n",
" image = np.array(image)[1:,:] #Convert to an array, leaving out the first row because the first row is just housekeeping data\n",
" image = image.astype(int)\n",
" row, col = image.shape\n",
" predict = np.empty([row,col]) # create a empty matrix to update prediction\n",
" predict[0,:] = np.copy(image[0,:]) # keep the first row from the image\n",
" predict[:,0] = np.copy(image[:,0]) # keep the first columen from the image\n",
" predict[-1,:] = np.copy(image[-1,:]) # keep the first row from the image\n",
" predict[:,-1] = np.copy(image[:,-1]) # keep the first columen from the image\n",
" diff = np.empty([row,col])\n",
" diff[0,:] = np.zeros(col) # keep the first row from the image\n",
" diff[:,0] = np.zeros(row)\n",
" diff[-1,:] = np.zeros(col) # keep the first row from the image\n",
" diff[:,-1] = np.zeros(row)\n",
" A = np.array([[3,0,-1],[0,3,3],[1,-3,-4]])\n",
" z0 = image[0:-2,0:-2]\n",
" z1 = image[0:-2,1:-1]\n",
" z2 = image[0:-2,2::]\n",
" z3 = image[1:-1,0:-2]\n",
" A = np.array([[3,0,-1],[0,3,3],[1,-3,-4]]) # the matrix for system of equation\n",
" z0 = image[0:-2,0:-2] # get all the first pixel for the entire image\n",
" z1 = image[0:-2,1:-1] # get all the second pixel for the entire image\n",
" z2 = image[0:-2,2::] # get all the third pixel for the entire image\n",
" z3 = image[1:-1,0:-2] # get all the forth pixel for the entire image\n",
" # calculate the out put of the system of equation\n",
" y0 = np.ravel(-z0+z2-z3)\n",
" y1 = np.ravel(z0+z1+z2)\n",
" y2 = np.ravel(-z0-z1-z2-z3)\n",
" y = np.vstack((y0,y1,y2))\n",
" # use numpy solver to solve the system of equations all at once\n",
" predict = np.linalg.solve(A,y)[-1]\n",
" \n",
"
# flatten the neighbor pixlels and stack them together
\n",
" z0 = np.ravel(z0)\n",
" z1 = np.ravel(z1)\n",
" z2 = np.ravel(z2)\n",
" z3 = np.ravel(z3)\n",
" neighbor = np.vstack((z0,z1,z2,z3)).T\n",
" # calculate the difference\n",
" diff = np.max(neighbor,axis = 1) - np.min(neighbor, axis=1)\n",
" \n",
"
# flatten the image to a vector
\n",
" image = np.ravel(image[1:-1,1:-1])\n",
" return image, predict, diff"
]
},
{
"cell_type": "code",
"execution_count":
44
,
"execution_count":
51
,
"id": "1bc0bed5",
"metadata": {},
"outputs": [],
...
...
@@ -287,8 +278,8 @@
},
{
"cell_type": "code",
"execution_count":
46
,
"id": "
a8c46fb2
",
"execution_count":
52
,
"id": "
0f908e6c
",
"metadata": {},
"outputs": [
{
...
...
@@ -296,7 +287,7 @@
"output_type": "stream",
"text": [
"mean of error = 18.740279058331875\n",
"time to run = 0.0
6311893463134766
\n"
"time to run = 0.0
7091403007507324
\n"
]
},
{
...
...
@@ -330,7 +321,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "
0c73bbe
2",
"id": "
fb798c3
2",
"metadata": {},
"outputs": [],
"source": []
...
...
@@ -338,7 +329,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "
1f19bb5d
",
"id": "
23f8c8a7
",
"metadata": {},
"outputs": [],
"source": []
...
...
prediction_MSE.ipynb
→
prediction_MSE
_kelly
.ipynb
View file @
5c7cf95e
...
...
@@ -19,7 +19,7 @@
},
{
"cell_type": "code",
"execution_count":
2
,
"execution_count":
44
,
"id": "b7a550e0",
"metadata": {},
"outputs": [],
...
...
@@ -74,7 +74,7 @@
},
{
"cell_type": "code",
"execution_count":
4
1,
"execution_count":
5
1,
"id": "9ed20f84",
"metadata": {},
"outputs": [],
...
...
@@ -91,33 +91,35 @@
" image = Image.open(image) #Open the image and read it as an Image object\n",
" image = np.array(image)[1:,:] #Convert to an array, leaving out the first row because the first row is just housekeeping data\n",
" image = image.astype(int)\n",
"
row, col = image.shape
\n",
"
A = np.array([[3,0,-1],[0,3,3],[1,-3,-4]])
\n",
" z
0 = image[0:-2,0:-2]
\n",
" z
1 = image[0:-2,1:-1]
\n",
" z
2 = image[0:-2,2::]
\n",
"
z3 = image[1:-1,0:-2]
\n",
"
A = np.array([[3,0,-1],[0,3,3],[1,-3,-4]]) # the matrix for system of equation
\n",
"
z0 = image[0:-2,0:-2] # get all the first pixel for the entire image
\n",
" z
1 = image[0:-2,1:-1] # get all the second pixel for the entire image
\n",
" z
2 = image[0:-2,2::] # get all the third pixel for the entire image
\n",
" z
3 = image[1:-1,0:-2] # get all the forth pixel for the entire image
\n",
"
# calculate the out put of the system of equation
\n",
" y0 = np.ravel(-z0+z2-z3)\n",
" y1 = np.ravel(z0+z1+z2)\n",
" y2 = np.ravel(-z0-z1-z2-z3)\n",
" y = np.vstack((y0,y1,y2))\n",
"\n",
" predict = np.linalg.solve(A,y
[:10]
)[-1]\n",
" \n",
"
# use numpy solver to solve the system of equations all at once
\n",
" predict = np.linalg.solve(A,y)[-1]\n",
"
# flatten the neighbor pixlels and stack them together
\n",
" z0 = np.ravel(z0)\n",
" z1 = np.ravel(z1)\n",
" z2 = np.ravel(z2)\n",
" z3 = np.ravel(z3)\n",
" neighbor = np.vstack((z0,z1,z2,z3)).T\n",
" diff = np.max(neighbor,axis = 1) - np.max(neighbor, axis=1)\n",
" \n",
" # calculate the difference\n",
" diff = np.max(neighbor,axis = 1) - np.min(neighbor, axis=1)\n",
" # flatten the image to a vector\n",
" image = np.ravel(image[1:-1,1:-1])\n",
" return image, predict, diff"
" return image, predict, diff\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 4
2
,
"execution_count": 4
9
,
"id": "8e3ef654",
"metadata": {},
"outputs": [],
...
...
@@ -150,7 +152,7 @@
},
{
"cell_type": "code",
"execution_count":
43
,
"execution_count":
52
,
"id": "fa65dcd6",
"metadata": {},
"outputs": [
...
...
@@ -160,8 +162,8 @@
"text": [
"Average Error First and Second Added: 20.017164930235474\n",
"Standard Deviaiton of Mean Errors: 0.16101183692475135\n",
"Average Difference:
-
53.678648426455226\n",
"Average Time per Image for First: 0.0
508149564266204
8\n"
"Average Difference: 53.678648426455226\n",
"Average Time per Image for First: 0.0
453574061393737
8\n"
]
}
],
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment