Beruflich Dokumente
Kultur Dokumente
Assignment no. 1
Submitted By:
Syed Hassan Raheem Shah {1412108}
Submitted To:
>> imwrite(f,'gems.jpg','quality',25)
>> imwrite(f,'gems.jpg','quality',5)
>> imwrite(f,'gems.jpg','quality',0)
Task 2: conversion of different classes
>> a=2.5
a=
2.5000
>> whos
Name Size Bytes Class Attributes
a 1x1 8 double
>> 3/4
ans =
0.7500
>> format long
>> 3/4
ans =
0.750000000000000
>> b= rand(3,3)
b=
0.814723686393179 0.913375856139019 0.278498218867048
0.905791937075619 0.632359246225410 0.546881519204984
0.126986816293506 0.097540404999410 0.957506835434298
>> x=3.2+4.5i
x=
3.200000000000000 + 4.500000000000000i
>> format short
>> x=3.2+4.5i
x=
3.2000 + 4.5000i
double
matrix =
double
>> whos
Name Size Bytes Class Attributes
matrix 1x6 12 char
object 3x3 72 double
Task 3: conversion of different types images
1 RGB to Gray
>> RGB=imread('1.jpg','jpg');
>> RGBtoGray=rgb2gray(RGB);
>>imshow(RGBtoGray);
2 GGBtoIndex
>> I1=imread('1.jpg');
>> imshow(I1);
>> [any,nothing]=rgb2ind(I1, 10);
>> imshow(any,nothing);
Sample is PNG
>> imread('AbeCX.PNG')
>> imwrite(sample,'AbeCX.bmp')
>> imwrite(sample,'AbeCX.tif')
>> imwrite(sample,'AbeCX.jpg')
Task 4: Logical Functions
>> f=false(3,3)
f=
3×3 logical array
0 0 0
0 0 0
0 0 0
>> t=true(3,3)
t=
3×3 logical array
1 1 1
1 1 1
1 1 1
OR Function
>> X = [1 0 0 1 1];
>> Y = [0 0 0 0 0];
>> any(X) || any(Y)
ans = logical 1
And Function
>> any(X) && any(Y)
ans = logical 0
Not Function on Identity Matrix
>> A=eye(4)
A=
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
>> B=~A
B = 4×4 logical array
0 1 1 1
1 0 1 1
1 1 0 1
1 1 1 0
Exclusive OR Logical Function
>> c=xor(A,B)
c=
4×4 logical array
1 1 1 1
1 1 1 1
1 1 1 1
1 1 1 1
Islogical Logical Function
>> islogical = islogical(A)
islogical = logical
0
>> y= 10:-2:0
y=
10 8 6 4 2 0
Index Matrix Row and Colmns
>>A=magic(3)
A= 3x3
8 1 6
3 5 7
4 9 2
>> [x,y]=size(i)
x=
3603
y=
14418
A= 0.7431
>> B=rand(5)
B=
0.3922 0.2769 0.3171 0.7655 0.6463
0.6555 0.0462 0.9502 0.7952 0.7094
0.1712 0.0971 0.0344 0.1869 0.7547
0.7060 0.8235 0.4387 0.4898 0.2760
0.0318 0.6948 0.3816 0.4456 0.6797
>> C=rand([2,3,2])
C(:,:,1) =
0.6551 0.1190 0.9597
0.1626 0.4984 0.3404
C(:,:,2) =
0.5853 0.7513 0.5060
0.2238 0.2551 0.6991
Task 10:
A. Imadd()
>> I1=imread('1.jpg'); >> I2=imread('2.jpg');
>> imshow(I1) >> imshow(I2)
>>add=imadd(I1,I2)
>> imshow(add);
B. imsubtract()
>> sub=imsubtract(I1,I2);
>> subI=imshow(sub);
C. immultiply()
>> mul=immultiply(I1,I2);
>> imshow(mul);
D. imdivide()
>> div=imdivide(I1,I2);
>> imshow(div);
E. imabsdiff()
>> dif=imabsdiff(I1,I2);
>> imshow(dif);
F. imcomplement()
>> com=imcomplement(I1);
>> imshow(I1);
G. imlincomb()
>> lin=imlincomb(1.5,I1);
>> imshow(lin)
Task 11: Logical function { iscell(), iscellstr(), ischar(), isempty(), isequal(),
isfield(),isfinite().
>> c=iscell(b);
>> disp(c);
0 False
B. iscellstr()
>> s='Hellow';
>> iscellstr(s);
>> disp(s);
Hellow
>> str = iscellstr(s);
>> disp(str);
0 False
C. ischar()
>> z=('A');
>> y=ischar(z);
>> disp(y);
1 True
>> z=('Asdf');
>> y=ischar(z);
>> disp(y);
0 False
D. isempty()
>> A(:,:,:) =[];
>> B=isempty(A);
>> disp(B);
1 True
>> A=rand(2,2,2);
>> B=isempty(A);
>> disp(B);
0 False
E. isequal()
>> a=45;
>> b=45;
>> z=isequal(a,b);
>> disp(z);
1 True
>> a=45;
>> b=40;
>> z=isequal(a,b);
>> disp(z);
0 False
F. isfield()
>> B=struct ('one',1,'tow',2);
>> fields = isfield(B,{'two','pi','One',3.14})
fields =
1×4 logical array
0 0 0 0
>> disp(fields);
0 0 0 0
G. isfinite()
>> A=1./[-2 -1 0 1 2]
A= -0.5000 -1.0000 Inf 1.0000 0.5000
>> Fin=isfinite(A);
>> disp(Fin);
1 1 0 1 1
Task 12: Function imadjust() and imtrans().
A. Imadjust()
imadjust(image,[low_in high_in],[low_out high_out],gamma)
B. imtransform()
>>I1=imread('1.jpg');
>> trans = maketform('affine',[1 0 0; .5 1 0; 0 0 1]);
>> transf= imtransform(I1,trans);
>> imshow(I1), figure, imshow(transf);