This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [x_std_dev] = hw2_01 | |
% generate 10 images of size 256x256 of pixel value 128 | |
x = ones(10,256,256)*128; | |
% apply gaussian noise | |
x = imnoise(x, 'gaussian', 0, 2.0); | |
% calculate standard deviation | |
x_std_dev = generate_std_dev(x); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [x_filtered_std_dev] = hw2_02 | |
% generate 10 images of size 256x256 of pixel value 128 | |
x = ones(10,256,256)*128; | |
% apply gaussian noise | |
x = imnoise(x, 'gaussian', 0, 2.0); | |
% solution for homework problem 2 | |
x_filtered = apply_box_filter(x, 3); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [x_filtered_std_dev] = hw2_03 | |
% generate 10 images of size 256x256 of pixel value 128 | |
x = ones(10,256,256)*128; | |
% apply gaussian noise | |
x = imnoise(x, 'gaussian', 0, 2.0); | |
% solution for homework problem 3 | |
x_filtered = imgaussfilt(x, 1.4); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [results] = hw2_04 | |
% provided matrix and filters | |
image_x = [10,10,10,10,10,40,40,40,40,40]; | |
filter_a = 1/5 * [1,1,1,1,1]; | |
filter_b = 1/10 * [1,2,4,2,1]; | |
% apply the filters to the image | |
results_a = conv2(image_x, filter_a, 'same'); | |
results_b = conv2(image_x, filter_b, 'same'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
# define size of the output | |
SIZE_OF_ARRAY = 50 | |
# start with an empty array | |
end_array = [] | |
for i in range(0, SIZE_OF_ARRAY): | |
temp_arr = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [A,B] = hw2_05 | |
% read in csv | |
matrix_input = csvread('hw2_05.csv'); | |
% before histogram | |
A = histogram(matrix_input); | |
% provided filter | |
filter = [-1,2,-1]; | |
% apply the filter to the image | |
matrix_input_post = conv2(matrix_input, filter, 'same'); | |
% after histogram |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function end_matrix = hw2_06 | |
% provided starting matrix | |
start_matrix = [0,-1,-2,-3,-4,-5,-6,-7; | |
1,0,-1,-2,-3,-4,-5,-6; | |
2,1,0,-1,-2,-3,-4,-5; | |
3,2,1,0,-1,-2,-3,-4; | |
4,3,2,1,0,-1,-2,-3; | |
5,4,3,2,1,0,-1,-2; | |
6,5,4,3,2,1,0,-1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function results = hw2_07 | |
start_matrix = [4,4,4,4,8,8,8,8]; | |
output_A = medfilt1(start_matrix, 3); | |
output_B = conv(start_matrix, [.25,.5,.25], 'same'); | |
results = [start_matrix;output_A;output_B]; | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# code to generate code seen in https://i.redd.it/azecoqeevyv41.jpg | |
MAX = 12 | |
print("\n\ndef function(num1, sign, num2):") | |
for i in range(MAX - 1): | |
for j in range(MAX - 1): | |
print("\tif num1 == " + str(i + 1) + " and sign == '*' and num2 == " + str(j + 1) + ":") | |
print("\t\tprint('" + str(i + 1) + "*" + str(j + 1) + "=" + str((i + 1)*(j + 1)) + "')") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# code for https://www.reddit.com/r/ProgrammerHumor/comments/gawu9i/and_using_light_theme/fp2rtxa/ | |
def function(num1, sign, num2): | |
if num1 == 1 and sign == '*' and num2 == 1: | |
print('1*1=1') | |
if num1 == 1 and sign == '*' and num2 == 2: | |
print('1*2=2') | |
if num1 == 1 and sign == '*' and num2 == 3: | |
print('1*3=3') | |
if num1 == 1 and sign == '*' and num2 == 4: |
OlderNewer