Skip to content

Instantly share code, notes, and snippets.

View MichaelTr7's full-sized avatar

MichaelTr7 MichaelTr7

View GitHub Profile
<link rel="icon" type="image/ico" href="./favicon.ico">
<link rel="shortcut icon" href="./favicons/favicon.ico">
<link rel="icon" type="image/png" sizes="16x16" href="./favicons/favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="./favicons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="48x48" href="./favicons/favicon-48x48.png">
<link rel="apple-touch-icon" sizes="57x57" href="./favicons/apple-touch-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="./favicons/apple-touch-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="./favicons/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="./favicons/apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="./favicons/apple-touch-icon-114x114.png">
File_Type = "png";
Image_File_Names = dir("*." + File_Type);
Image_Row_Vector = [];
for Image_Index=1: numel(Image_File_Names)
File_Name = Image_File_Names(Image_Index).name;
Image = imread(File_Name);
Image = reshape(Image,[1,numel(Image)]);
Image_Row_Vector = [Image_Row_Vector Image];
end
@MichaelTr7
MichaelTr7 / Histogram.m
Last active February 6, 2022 22:38
Retrieving histogram of greyscale image in MATLAB (without imhist() and histogram() functions).
clc;
clear;
clf;
Image = rgb2gray(imread("peppers.png"));
Bins = zeros(256,1);
for Intensity = 0: 255
Bins(Intensity+1) = nnz(Image == Intensity);
end
@MichaelTr7
MichaelTr7 / Bitmap.m
Created April 29, 2021 14:13
A MATLAB script to convert black and white images (.png) to bitmaps (.bmp).
%Convert black and white image to binary%
File_Name = "Bitmap_Sample.png";
Image = imread(File_Name);
Image = imbinarize(Image);
imwrite(Image,"Bitmap_Sample.bmp");
@MichaelTr7
MichaelTr7 / Unit_Step_Function.m
Created April 14, 2021 17:14
A MATLAB script that defines a function in terms of the basic unit step.
%% FUNDAMENTAL UNIT STEP FUNCTION %%
%Subplot dimensions%
Rows = 3;
Columns = 1;
u = @(n) (n >= 0);
subplot(Rows,Columns,1); fplot(u);
title("Unit Step Function");
xlim([-5 5]);
@MichaelTr7
MichaelTr7 / Load_MAT_Files.m
Last active April 8, 2021 18:33
A MATLAB Script for Loading MAT files from folders.
Folder_Directory = "";
MAT_Files = dir(fullfile(Folder_Directory,"*.mat"));
for File_Number = 1: length(MAT_Files)
load(fullfile(Folder_Directory,MAT_Files(File_Number).name));
end
@MichaelTr7
MichaelTr7 / Curve_Fitting.m
Last active April 8, 2021 18:01
A MATLAB script for curve fitting a plot of data-points.
%Curve Fitting and Publishing MATLAB Code as a PDF%
Random_Data_Y = [0 0.141 0.205 0.271 0.371 0.437 0.444];
Random_Data_X = [2.42 104 112 119 126 131 131];
%Preparing data to be curved fitted%
[Random_Data_X, Random_Data_Y] = prepareCurveData(Random_Data_X, Random_Data_Y);
%Applying type of curve fitting%
f = fit(Random_Data_X, Random_Data_Y,'smoothingspline');
@MichaelTr7
MichaelTr7 / Split_Image.m
Last active December 8, 2022 23:33
MATLAB script that splits an image into blocks/tiles.
clf;
Image = imread("peppers.png");
[Image_Height,Image_Width,Number_Of_Colour_Channels] = size(Image);
Block_Size = 50;
Number_Of_Blocks_Vertically = ceil(Image_Height/Block_Size);
Number_Of_Blocks_Horizontally = ceil(Image_Width/Block_Size);
Image_Blocks = struct('Blocks',[]);
Index = 1;
@MichaelTr7
MichaelTr7 / Grab_Video_Frames.m
Last active March 30, 2021 01:34
A MATLAB function to extract the frames from a video file.
function [Frame_Data,Video_Structure] = Grab_Video_Frames(File_Name)
Video_Properties = VideoReader(File_Name);
Video_Height = Video_Properties.Height;
Video_Width = Video_Properties.Width;
Number_Of_Frames = Video_Properties.NumFrames;
Colour_Channel_Matrix = zeros(Video_Height,Video_Width,3,'uint8');
Video_Structure = struct('cdata',Colour_Channel_Matrix,'colormap',[]);
@MichaelTr7
MichaelTr7 / Modal.html
Last active April 8, 2021 18:34
A HTML/CSS/JavaScript Sliding Modal or Notifications.
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>CSS Modal</title>
<link rel="stylesheet" href="./Style.css">
<script type="text/javascript" src="./Modal.js"></script>
</head>
<body>