-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
image processing basics and other stuff
- Loading branch information
1 parent
6b3f5b3
commit c162ed2
Showing
34 changed files
with
321 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
%hold example | ||
a = linspace(1,2*pi); | ||
b = sin(a); | ||
c = sin(a*2); | ||
d = sin(a*3/2); | ||
% ab teeno p se comment htane p bhi sirf 3rd waala graph bchta h so if | ||
% someone wanted all 3 graphs nt possible without hold , unless he plans to | ||
% use subplot | ||
hold on; | ||
|
||
plot(a,b,'green'); | ||
plot(a,c,'magenta'); | ||
plot(a,d,'cyan'); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
%subplot example | ||
a = linspace(1,2*pi); | ||
b = sin(a); | ||
c = sin(a*2); | ||
d = sin(a*3/2); | ||
|
||
subplot(3,1,1); | ||
plot(a,b,'green'); | ||
|
||
subplot(3,1,2); | ||
plot(a,c,'magenta'); | ||
|
||
subplot(3,1,3); | ||
plot(a,d,'cyan'); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
1) contrast enhancement by histogram equalization | ||
2) imshow , double , bit planes |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
clc;clear all; | ||
img = imread('images/god.jpg'); | ||
img = rgb2gray(img); | ||
x = bitget(img,8); | ||
|
||
x = uint8(x*255); | ||
imshow(x); | ||
imwrite(x,'images/bitplane.jpg'); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
clc;clear all; | ||
|
||
mycolormap = []; | ||
|
||
for i = 1:32 | ||
mycolormap(i,1) = (i)/255; | ||
mycolormap(i,2) = (i)/255; | ||
mycolormap(i,3) = 0; | ||
end; | ||
|
||
for i = 33:64 | ||
mycolormap(i,1) = 0; | ||
mycolormap(i,2) = (i/2)/255; | ||
mycolormap(i,3) = (i/2)/255; | ||
end; | ||
|
||
for i = 65:96 | ||
mycolormap(i,1) = (i/3)/255; | ||
mycolormap(i,2) = 0; | ||
mycolormap(i,3) = (i/3)/255; | ||
end; | ||
img = imread('images/god.jpg'); | ||
%colormap(mycolormap); | ||
|
||
colormap hsv; | ||
|
||
cmap = colormap; | ||
indexedimg = rgb2ind(img,cmap); | ||
imshow(indexedimg); | ||
|
||
|
||
%imwrite(indexedimg,'images/darklord.jpg'); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
clc;clear all; | ||
img=imread('images/god.jpg'); | ||
I=rgb2gray(img); | ||
BW1 = edge(I,'sobel'); | ||
BW2 = edge(I,'canny'); | ||
figure; | ||
imshowpair(BW1,BW2,'montage') %new function for displaying multiple graphs! | ||
title('Sobel Filter Canny Filter'); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
% we'll cretae our own image data array | ||
a = []; | ||
|
||
k = 100; | ||
|
||
for i = 1:k | ||
for j = 1:k | ||
a(i,j,1) = 20 + floor(rand()*235); | ||
a(i,j,2) = 30 + floor(rand()*225); | ||
a(i,j,3) = floor(rand()*255); | ||
end; | ||
end; | ||
grayimg = rgb2gray(a); | ||
[a,b] = imhist(grayimg); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
clc;clear; | ||
|
||
img=imread('images/god.jpg'); | ||
[x, map]=rgb2ind(img,256); | ||
f1 = ones(4)/16; | ||
image=filter2(f1, x); | ||
|
||
subplot(121); | ||
imshow(img); | ||
subplot(122); | ||
imshow(image); | ||
%used indexed image, but no idea about the result | ||
%use ye waala filter for grayscale, rgb me average k liye alag filter hai | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
img=imread('images/god.jpg'); | ||
|
||
radius=27; | ||
h=fspecial('disk',radius); | ||
|
||
edge=fspecial('sobel'); | ||
|
||
|
||
image1=imfilter(img,h,'replicate'); | ||
image2=imfilter(img,edge,'replicate'); | ||
|
||
subplot(221); | ||
imshow(img); | ||
subplot(222); | ||
imshow(image1); | ||
subplot(223); | ||
imshow(image2); | ||
|
||
%sobel is used in edge detection | ||
|
||
img=imnoise(img,'salt & pepper',0.2); | ||
%subplot(224); imshow(img); | ||
imr=medfilt2(img(:,:,1),[3 3]); | ||
imgr=medfilt2(img(:,:,2),[3 3]); | ||
imb=medfilt2(img(:,:,3),[3 3]); | ||
image3=cat(3, imr, imgr, imb); | ||
subplot(224); | ||
imshow(image3); | ||
|
||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
% it is read into a 3d array | ||
img = imread('god.jpg'); | ||
|
||
a = size(img); | ||
%display(a(1,2)); | ||
% display displays vars to the command window | ||
|
||
padding = zeros(a(1,1),a(1,2)); | ||
|
||
% the colon serves as a wildcard entry so that all values in the red are | ||
% selected in all rows and columns | ||
redimg = cat(3,img(:,:,1),padding,padding); | ||
blueimg = cat(3,padding,img(:,:,2),padding); | ||
greenimg = cat(3,padding,padding,img(:,:,3)); | ||
|
||
% imshow takes the raw image array data and makes it into a figure , | ||
subplot(1,3,1); | ||
imshow(redimg); | ||
|
||
subplot(1,3,2); | ||
imshow(greenimg); | ||
|
||
subplot(1,3,3); | ||
imshow(blueimg); | ||
|
||
% how to multiline comment in matlab ? %{%} this is a rarely used feature | ||
figure ; imshow(redimg); | ||
figure ; imshow(blueimg); | ||
figure ; imshow(greenimg); | ||
|
||
imwrite(redimg,'redgod.png'); | ||
imwrite(greenimg,'greengod.png'); | ||
imwrite(blueimg,'bluegod.png'); | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
img=imread('images/god.jpg'); | ||
|
||
colormap jet; | ||
cmap1 = colormap; | ||
|
||
colormap default; | ||
cmap2 = colormap; | ||
|
||
colormap gray; | ||
cmap3 = colormap; | ||
|
||
colormap winter; | ||
mycmap = colormap; | ||
|
||
%[indimg,map] = rgb2ind(img,150); | ||
|
||
figure ; | ||
imshow(rgb2ind(img,cmap3)); | ||
colormap(cmap3); | ||
|
||
figure; | ||
imshow(rgb2ind(img,cmap2)); | ||
colormap(cmap2); | ||
|
||
figure; | ||
imshow(rgb2ind(img,cmap1)); | ||
colormap(cmap1); | ||
|
||
figure; | ||
imshow(rgb2ind(img,mycmap)); | ||
colormap(mycmap); | ||
|
||
%imwrite(imdimg,'images/oilpainting_255bins.jpg'); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
img = imread('images/god.jpg'); | ||
a = size(img); | ||
|
||
for i = 1:a(1,1) | ||
for j = 1:a(1,2) | ||
% manipulating these relation infinite number of effects can be | ||
% formed | ||
% for invert change this to img(i,j,k) = 255 - img(i,j,k); | ||
img(i,j,1) = (img(i,j,1) * .393) + (img(i,j,2) *.769) + (img(i,j,3) * .189); | ||
img(i,j,2) = (img(i,j,1)* .349) + (img(i,j,2) *.686) + (img(i,j,3) * .168); | ||
img(i,j,3) = (img(i,j,1) * .272) + (img(i,j,2) *.534) + (img(i,j,3) * .131); | ||
end; | ||
end; | ||
|
||
imshow(img); | ||
%imwrite('images/invertedgod.jpg'); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@echo off | ||
echo ""> newfile.m |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
function f = modfloor(n,k) | ||
f = mod(floor(n/2),2); | ||
for i=1:k-1 | ||
f = mod(floor(f/2),2); | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
a = linspace(1,2*pi); | ||
b = sin(a); | ||
c = sin(2*a); | ||
|
||
plot(a,b,a,c); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
img = imread('images/god.jpg'); | ||
gray = rgb2gray(img); | ||
|
||
imadj = imadjust(img,[0,0.85],[]); | ||
k = 5; | ||
for i=1:k*k | ||
subplot(k,k,i); | ||
imadj = imadjust(imadj,[0,0.85],[]); | ||
imshow(imadj); | ||
end; | ||
|
||
% ruk what are we trying to do just jot it down agr 2*2 plots h | ||
% to i runs from 1:2 so we need subplot(2,2,1/2/3/4) 1+0,1+1,2+1,2+2 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
img = imread('images/god.jpg'); | ||
a = size(img); | ||
|
||
for i = 1:a(1,1) | ||
for j=1:a(1,2) | ||
img(i,j,1) = 0.2126*img(i,j,1) +0.7152*img(i,j,2)+0.0722*img(i,j,3); | ||
img(i,j,2) = 0.2126*img(i,j,1) +0.7152*img(i,j,2)+0.0722*img(i,j,3); | ||
img(i,j,3) = 0.2126*img(i,j,1) +0.7152*img(i,j,2)+0.0722*img(i,j,3); | ||
end | ||
end; | ||
|
||
imshow(img); | ||
imwrite(img,'images/grayscale.jpg') |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
img = imread('images/god.jpg'); | ||
grayimg = rgb2gray(img); | ||
bwimage = im2bw(img); | ||
|
||
a = size(img); | ||
|
||
padding = zeros(a(1,1),a(1,2)); | ||
redimg = cat(3,img(:,:,1),padding,padding); | ||
blueimg = cat(3,padding,img(:,:,2),padding); | ||
greenimg = cat(3,padding,padding,img(:,:,3)); | ||
|
||
[yRed,x] = imhist(img(:,:,1)); | ||
[yGreen,x] = imhist(img(:,:,2)); | ||
[yBlue,x] = imhist(img(:,:,3)); | ||
|
||
hold on; | ||
plot(x,yRed,'red'); | ||
plot(x,yGreen,'green'); | ||
plot(x,yBlue,'blue'); | ||
%{ | ||
subplot(1,3,1); | ||
plot(x,yRed,x,yGreen,x,yBlue); | ||
subplot(1,3,2); | ||
imhist(grayimg); | ||
subplot(1,3,3); | ||
imhist(bwimage); | ||
%} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
clc; clear all; | ||
img=imread('images/god.jpg'); | ||
img=rgb2gray(img); | ||
imgd=im2double(img); | ||
|
||
imgd=imnoise(imgd, 'salt & pepper', 0.02); %0.02 gives density of noise | ||
f=ones(3,3)/9; | ||
image=filter2(f,imgd); | ||
subplot(221); | ||
imshow(imgd); | ||
subplot(222); | ||
imshow(image); | ||
%works!!!! | ||
|
||
%mean filter just blurrs the image, not much useful | ||
%trying median filter | ||
|
||
betterimage=medfilt2(imgd); | ||
subplot(223); | ||
imshow(betterimage); | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
octave docs | ||
|
||
https://www.gnu.org/software/octave/doc/interpreter/ | ||
|
||
matlab | ||
|
||
http://www.bogotobogo.com/Matlab/ | ||
|
||
speech processing http://www.mathworks.com/matlabcentral/profile/authors/4428430-speech-processing | ||
|
||
|
||
https://sites.google.com/site/butwhymath/m/convolution ( convolution ) |