SlideShare a Scribd company logo
1 of 15
clear all,clc
I = imread('Market.png');
I=rgb2gray(I);

fun = @dct2;
mn=max(max(I))
% I1=im2double(I);

I2=I-128;
mn2=max(max(I2))

J = blkproc(I2,[8 8],fun);
imagesc(J), colormap(hot)

fun2=@idct2;

J1 = blkproc(J,[8 8],fun2);

figure(2),imshow(uint8(J1));
Original Image
After restoring the image without
           shifting back
After shifting back some values are
                 lost
We see a problem with the values
                 under 127
•   I(9:16,9:16)

•   ans =

•    45     56   81   129 148 151 152 145
•    43     46   69   115 147 154 152 147
•    41     44   59   96 138 151 153 152
•    38     40   52   78 124 148 152 151
•    39     42   47   59 104 139 151 148
•    46     43   45   47 89 130 150 152
•    56     46   44   44 71 114 146 152
•    61     45   40   47 50 95 138 149

•   >> I3(9:16,9:16)

•   ans =

•    128     128      128   129   148   151   152   145
•    128     128      128   128   147   154   152   147
•    128     128      128   128   138   151   153   152
•    128     128      128   128   128   148   152   151
•    128     128      128   128   128   139   151   148
•    128     128      128   128   128   130   150   152
•    128     128      128   128   128   128   146   152
•    128     128      128   128   128   128   138   149
Now fixing the values using int16
clear all,clc
I = imread('Market.png');
I=rgb2gray(I);

I=int16(I);
fun = @dct2;
mn=max(max(I))
% I1=im2double(I);

I2=I-128;
mn2=max(max(I2))

J = blkproc(I2,[8 8],fun);
imagesc(J), colormap(hot)
title('Color map of DCT of image');

fun2=@idct2;

J1 = blkproc(J,[8 8],fun2);

J1=J1+128;


figure(2),imshow(uint8(J1));

title('Restoring the image after shifting back');
Shifting before the DCT
J(1:8,1:8)

ans =

-638.8750 -29.3727 4.1062 -16.0527 0.1250 -7.0450 -0.2126 -4.8849
  85.6364 65.3826 33.3134 -17.2827 8.4377 -6.4442 -0.1027 -3.7384
 -39.9354 -15.6904 30.2180 9.2577 4.1787 -2.2267 2.9812 2.4027
  2.5924 -13.6623 -5.4940 -7.8364 3.6032 2.0654 1.9024 -1.0399
  2.3750 4.8097 8.6232 -5.1047 -5.6250 0.9445 0.8930 0.3232
  2.9945 -3.2131 -0.8315 6.9848 4.8601 0.3043 -1.6718 1.9621
  1.2530 -0.0697 0.7312 -0.2981 1.9222 2.9600 -0.7180 -2.5778
  2.9642 0.1810 -0.3388 -2.6802 0.8737 -1.0296 -2.5350 -1.8505

>> J(9:16,9:16)

ans =

-258.2500 -337.8517 15.4053 44.1097 -3.0000 3.1585 -0.6985 2.7715
 93.1163 -12.7923 -105.2548 6.4951 21.3826 -6.4124 -5.7623 -1.4411
  3.9429 29.0674 5.5570 -20.2654 8.7304 15.5683 -4.3624 -6.9161
  6.3625 -0.4752 -3.8135 1.3667 -8.5273 -3.2138 1.0229 2.4084
 -4.7500 5.8781 -0.2078 -5.6255 -0.5000 3.6717 -1.8081 -3.3458
  5.5093 -0.4890 -0.0957 -0.4586 -0.3461 -1.6795 0.1375 1.1942
 -0.2802 0.6512 1.8876 -2.0940 0.1721 -0.2394 -0.8070 -0.5737
  0.1225 1.8141 1.4955 -0.7570 -1.3032 -0.4243 -1.4556 0.1052
Now without shifting
DCT without shifting
J(1:8,1:8)

ans =

 385.1250 -29.3727 4.1062 -16.0527 0.1250 -7.0450 -0.2126 -4.8849
  85.6364 65.3826 33.3134 -17.2827 8.4377 -6.4442 -0.1027 -3.7384
 -39.9354 -15.6904 30.2180 9.2577 4.1787 -2.2267 2.9812 2.4027
  2.5924 -13.6623 -5.4940 -7.8364 3.6032 2.0654 1.9024 -1.0399
  2.3750 4.8097 8.6232 -5.1047 -5.6250 0.9445 0.8930 0.3232
  2.9945 -3.2131 -0.8315 6.9848 4.8601 0.3043 -1.6718 1.9621
  1.2530 -0.0697 0.7312 -0.2981 1.9222 2.9600 -0.7180 -2.5778
  2.9642 0.1810 -0.3388 -2.6802 0.8737 -1.0296 -2.5350 -1.8505

>> J(9:16,9:16)

ans =

 765.7500 -337.8517 15.4053 44.1097 -3.0000 3.1585 -0.6985 2.7715
 93.1163 -12.7923 -105.2548 6.4951 21.3826 -6.4124 -5.7623 -1.4411
  3.9429 29.0674 5.5570 -20.2654 8.7304 15.5683 -4.3624 -6.9161
  6.3625 -0.4752 -3.8135 1.3667 -8.5273 -3.2138 1.0229 2.4084
 -4.7500 5.8781 -0.2078 -5.6255 -0.5000 3.6717 -1.8081 -3.3458
  5.5093 -0.4890 -0.0957 -0.4586 -0.3461 -1.6795 0.1375 1.1942
 -0.2802 0.6512 1.8876 -2.0940 0.1721 -0.2394 -0.8070 -0.5737
  0.1225 1.8141 1.4955 -0.7570 -1.3032 -0.4243 -1.4556 0.1052
Why Shift data?
• Because the DCT is designed to work on pixel
  values ranging from -128 to 127, the original
  block is “leveled off” by subtracting 128 from
  each entry.
With shifting DC component
    becomes negative
dct2(int16(I(17:24,17:24))-128)

ans =

-257.2500 113.9048 190.8229 -14.2258 -31.7500 -26.0361 -7.0623 2.5148
 -2.2054 -19.3567 26.7378 49.5825 18.4131 11.2723 -8.1334 -1.2940
 -3.0683 -6.7897 -8.6176 -2.1773 0.6929 2.1958 0.9660 -1.2293
  2.3132 3.9376 3.2723 8.6746 4.5256 2.9021 1.4571 1.7553
     0 1.4061 -3.0190 -1.6145 1.5000 1.3845 -0.1025 -2.3183
 -0.8553 -1.8905 2.8431 0.5789 3.0710 -1.4592 0.0228 -1.5351
 -4.1410 2.3969 2.2160 2.8282 -0.2870 -0.1222 -0.1324 1.9538
  1.8516 1.3828 -0.3954 2.7004 0.8187 1.7177 -0.6069 -1.3586

K>> dct2(int16(I(17:24,17:24)))

ans =

 766.7500 113.9048 190.8229 -14.2258 -31.7500 -26.0361 -7.0623 2.5148
 -2.2054 -19.3567 26.7378 49.5825 18.4131 11.2723 -8.1334 -1.2940
 -3.0683 -6.7897 -8.6176 -2.1773 0.6929 2.1958 0.9660 -1.2293
  2.3132 3.9376 3.2723 8.6746 4.5256 2.9021 1.4571 1.7553
     0 1.4061 -3.0190 -1.6145 1.5000 1.3845 -0.1025 -2.3183
 -0.8553 -1.8905 2.8431 0.5789 3.0710 -1.4592 0.0228 -1.5351
 -4.1410 2.3969 2.2160 2.8282 -0.2870 -0.1222 -0.1324 1.9538
  1.8516 1.3828 -0.3954 2.7004 0.8187 1.7177 -0.6069 -1.3586

More Related Content

What's hot

solucionario mecanica vectorial para ingenieros - beer & johnston (dinamica)...
solucionario mecanica vectorial para ingenieros - beer  & johnston (dinamica)...solucionario mecanica vectorial para ingenieros - beer  & johnston (dinamica)...
solucionario mecanica vectorial para ingenieros - beer & johnston (dinamica)...
Sohar Carr
 
vibration of machines and structures
vibration of machines and structuresvibration of machines and structures
vibration of machines and structures
Aniruddhsinh Barad
 
Analisis gap dan thurstone
Analisis gap dan thurstoneAnalisis gap dan thurstone
Analisis gap dan thurstone
M Taufiq Budi H
 
Solución al ejercicio 1
Solución al ejercicio 1Solución al ejercicio 1
Solución al ejercicio 1
Jesthiger Cohil
 
solucionario mecanica vectorial para ingenieros - beer & johnston (dinamica)...
solucionario mecanica vectorial para ingenieros - beer  & johnston (dinamica)...solucionario mecanica vectorial para ingenieros - beer  & johnston (dinamica)...
solucionario mecanica vectorial para ingenieros - beer & johnston (dinamica)...
Sohar Carr
 
Cap 03
Cap 03Cap 03
Cap 03
UO
 
Solution shigley's
Solution shigley'sSolution shigley's
Solution shigley's
Alemu Abera
 

What's hot (18)

solucionario mecanica vectorial para ingenieros - beer & johnston (dinamica)...
solucionario mecanica vectorial para ingenieros - beer  & johnston (dinamica)...solucionario mecanica vectorial para ingenieros - beer  & johnston (dinamica)...
solucionario mecanica vectorial para ingenieros - beer & johnston (dinamica)...
 
Poster of surveying tasks
Poster of surveying tasksPoster of surveying tasks
Poster of surveying tasks
 
vibration of machines and structures
vibration of machines and structuresvibration of machines and structures
vibration of machines and structures
 
Capítulo 02 considerações estatísticas
Capítulo 02   considerações estatísticasCapítulo 02   considerações estatísticas
Capítulo 02 considerações estatísticas
 
Analisis gap dan thurstone
Analisis gap dan thurstoneAnalisis gap dan thurstone
Analisis gap dan thurstone
 
Solución al ejercicio 1
Solución al ejercicio 1Solución al ejercicio 1
Solución al ejercicio 1
 
電路學 - [第二章] 電路分析方法
電路學 - [第二章] 電路分析方法電路學 - [第二章] 電路分析方法
電路學 - [第二章] 電路分析方法
 
solucionario mecanica vectorial para ingenieros - beer & johnston (dinamica)...
solucionario mecanica vectorial para ingenieros - beer  & johnston (dinamica)...solucionario mecanica vectorial para ingenieros - beer  & johnston (dinamica)...
solucionario mecanica vectorial para ingenieros - beer & johnston (dinamica)...
 
W ee network_theory_10-06-17_ls2-sol
W ee network_theory_10-06-17_ls2-solW ee network_theory_10-06-17_ls2-sol
W ee network_theory_10-06-17_ls2-sol
 
Design of a Lift Mechanism for Disabled People
Design of a Lift Mechanism for Disabled PeopleDesign of a Lift Mechanism for Disabled People
Design of a Lift Mechanism for Disabled People
 
Deep Learning A-Z™: Artificial Neural Networks (ANN) - How do Neural Networks...
Deep Learning A-Z™: Artificial Neural Networks (ANN) - How do Neural Networks...Deep Learning A-Z™: Artificial Neural Networks (ANN) - How do Neural Networks...
Deep Learning A-Z™: Artificial Neural Networks (ANN) - How do Neural Networks...
 
Cap 12
Cap 12Cap 12
Cap 12
 
Clase 16 dsp
Clase 16 dspClase 16 dsp
Clase 16 dsp
 
Cap 03
Cap 03Cap 03
Cap 03
 
Sol cap 10 edicion 8
Sol cap 10   edicion 8Sol cap 10   edicion 8
Sol cap 10 edicion 8
 
Solution shigley's
Solution shigley'sSolution shigley's
Solution shigley's
 
Capítulo 10 mola
Capítulo 10   molaCapítulo 10   mola
Capítulo 10 mola
 
電路學 - [第八章] 磁耦合電路
電路學 - [第八章] 磁耦合電路電路學 - [第八章] 磁耦合電路
電路學 - [第八章] 磁耦合電路
 

Similar to Image dct shifting

Matlab Assignment JK Institute
Matlab Assignment JK InstituteMatlab Assignment JK Institute
Matlab Assignment JK Institute
Om Prakash
 
Arna Friend Controls II Final
Arna Friend Controls II FinalArna Friend Controls II Final
Arna Friend Controls II Final
Arna Friend
 

Similar to Image dct shifting (20)

Convolution as matrix multiplication
Convolution as matrix multiplicationConvolution as matrix multiplication
Convolution as matrix multiplication
 
Ejerciciooo3
Ejerciciooo3Ejerciciooo3
Ejerciciooo3
 
Matlab Assignment JK Institute
Matlab Assignment JK InstituteMatlab Assignment JK Institute
Matlab Assignment JK Institute
 
Data Science Is More Than Just Statistics
Data Science Is More Than Just StatisticsData Science Is More Than Just Statistics
Data Science Is More Than Just Statistics
 
Tablas normal chi cuadrado y t student 1-semana 6
Tablas normal chi cuadrado y t student 1-semana 6Tablas normal chi cuadrado y t student 1-semana 6
Tablas normal chi cuadrado y t student 1-semana 6
 
Introduction to MATLAB
Introduction to MATLAB Introduction to MATLAB
Introduction to MATLAB
 
project designa.docx
project designa.docxproject designa.docx
project designa.docx
 
Discrete cosine Transform and Digital Image compression.ppt
Discrete cosine Transform and Digital Image compression.pptDiscrete cosine Transform and Digital Image compression.ppt
Discrete cosine Transform and Digital Image compression.ppt
 
Geometry Commands
Geometry CommandsGeometry Commands
Geometry Commands
 
Attention-Based Adaptive Selection of Operations for Image Restoration in the...
Attention-Based Adaptive Selection of Operations for Image Restoration in the...Attention-Based Adaptive Selection of Operations for Image Restoration in the...
Attention-Based Adaptive Selection of Operations for Image Restoration in the...
 
Scaling the #2ndhalf
Scaling the #2ndhalfScaling the #2ndhalf
Scaling the #2ndhalf
 
Financial Data Mining Talk
Financial Data Mining TalkFinancial Data Mining Talk
Financial Data Mining Talk
 
Compressible Flow Tables and Plots
Compressible Flow Tables and PlotsCompressible Flow Tables and Plots
Compressible Flow Tables and Plots
 
Arna Friend Controls II Final
Arna Friend Controls II FinalArna Friend Controls II Final
Arna Friend Controls II Final
 
Acrylic gearbox creative journey
Acrylic gearbox creative journeyAcrylic gearbox creative journey
Acrylic gearbox creative journey
 
Tarea 2 hidraulica iii-cabrera arias roberto alejandro
Tarea 2 hidraulica iii-cabrera arias roberto alejandroTarea 2 hidraulica iii-cabrera arias roberto alejandro
Tarea 2 hidraulica iii-cabrera arias roberto alejandro
 
Ch02
Ch02Ch02
Ch02
 
Perhitunngan
PerhitunnganPerhitunngan
Perhitunngan
 
Calculation template
Calculation templateCalculation template
Calculation template
 
Elliptic Curve Cryptography
Elliptic Curve CryptographyElliptic Curve Cryptography
Elliptic Curve Cryptography
 

More from Amr Nasr (16)

Comparison of image fusion methods
Comparison of image fusion methodsComparison of image fusion methods
Comparison of image fusion methods
 
6 big google buys of 2012
6 big google buys of 20126 big google buys of 2012
6 big google buys of 2012
 
Video watermarking
Video watermarkingVideo watermarking
Video watermarking
 
Scaling compression2
Scaling compression2Scaling compression2
Scaling compression2
 
Compression one example
Compression one exampleCompression one example
Compression one example
 
Video watermarking
Video watermarkingVideo watermarking
Video watermarking
 
Watermark
WatermarkWatermark
Watermark
 
Whitebalance
WhitebalanceWhitebalance
Whitebalance
 
Wavelet
WaveletWavelet
Wavelet
 
Wavelet watermark level3
Wavelet watermark level3Wavelet watermark level3
Wavelet watermark level3
 
Wavelet watermark level2
Wavelet watermark level2Wavelet watermark level2
Wavelet watermark level2
 
Two dimensional true wavelet compression
Two dimensional true wavelet compressionTwo dimensional true wavelet compression
Two dimensional true wavelet compression
 
Image fft
Image fftImage fft
Image fft
 
Tcp snoop protocols
Tcp snoop protocols  Tcp snoop protocols
Tcp snoop protocols
 
Digital forensics lessons
Digital forensics lessons   Digital forensics lessons
Digital forensics lessons
 
Crypt
CryptCrypt
Crypt
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Recently uploaded (20)

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 

Image dct shifting

  • 1.
  • 2. clear all,clc I = imread('Market.png'); I=rgb2gray(I); fun = @dct2; mn=max(max(I)) % I1=im2double(I); I2=I-128; mn2=max(max(I2)) J = blkproc(I2,[8 8],fun); imagesc(J), colormap(hot) fun2=@idct2; J1 = blkproc(J,[8 8],fun2); figure(2),imshow(uint8(J1));
  • 4. After restoring the image without shifting back
  • 5. After shifting back some values are lost
  • 6. We see a problem with the values under 127 • I(9:16,9:16) • ans = • 45 56 81 129 148 151 152 145 • 43 46 69 115 147 154 152 147 • 41 44 59 96 138 151 153 152 • 38 40 52 78 124 148 152 151 • 39 42 47 59 104 139 151 148 • 46 43 45 47 89 130 150 152 • 56 46 44 44 71 114 146 152 • 61 45 40 47 50 95 138 149 • >> I3(9:16,9:16) • ans = • 128 128 128 129 148 151 152 145 • 128 128 128 128 147 154 152 147 • 128 128 128 128 138 151 153 152 • 128 128 128 128 128 148 152 151 • 128 128 128 128 128 139 151 148 • 128 128 128 128 128 130 150 152 • 128 128 128 128 128 128 146 152 • 128 128 128 128 128 128 138 149
  • 7. Now fixing the values using int16 clear all,clc I = imread('Market.png'); I=rgb2gray(I); I=int16(I); fun = @dct2; mn=max(max(I)) % I1=im2double(I); I2=I-128; mn2=max(max(I2)) J = blkproc(I2,[8 8],fun); imagesc(J), colormap(hot) title('Color map of DCT of image'); fun2=@idct2; J1 = blkproc(J,[8 8],fun2); J1=J1+128; figure(2),imshow(uint8(J1)); title('Restoring the image after shifting back');
  • 8.
  • 9.
  • 10. Shifting before the DCT J(1:8,1:8) ans = -638.8750 -29.3727 4.1062 -16.0527 0.1250 -7.0450 -0.2126 -4.8849 85.6364 65.3826 33.3134 -17.2827 8.4377 -6.4442 -0.1027 -3.7384 -39.9354 -15.6904 30.2180 9.2577 4.1787 -2.2267 2.9812 2.4027 2.5924 -13.6623 -5.4940 -7.8364 3.6032 2.0654 1.9024 -1.0399 2.3750 4.8097 8.6232 -5.1047 -5.6250 0.9445 0.8930 0.3232 2.9945 -3.2131 -0.8315 6.9848 4.8601 0.3043 -1.6718 1.9621 1.2530 -0.0697 0.7312 -0.2981 1.9222 2.9600 -0.7180 -2.5778 2.9642 0.1810 -0.3388 -2.6802 0.8737 -1.0296 -2.5350 -1.8505 >> J(9:16,9:16) ans = -258.2500 -337.8517 15.4053 44.1097 -3.0000 3.1585 -0.6985 2.7715 93.1163 -12.7923 -105.2548 6.4951 21.3826 -6.4124 -5.7623 -1.4411 3.9429 29.0674 5.5570 -20.2654 8.7304 15.5683 -4.3624 -6.9161 6.3625 -0.4752 -3.8135 1.3667 -8.5273 -3.2138 1.0229 2.4084 -4.7500 5.8781 -0.2078 -5.6255 -0.5000 3.6717 -1.8081 -3.3458 5.5093 -0.4890 -0.0957 -0.4586 -0.3461 -1.6795 0.1375 1.1942 -0.2802 0.6512 1.8876 -2.0940 0.1721 -0.2394 -0.8070 -0.5737 0.1225 1.8141 1.4955 -0.7570 -1.3032 -0.4243 -1.4556 0.1052
  • 12. DCT without shifting J(1:8,1:8) ans = 385.1250 -29.3727 4.1062 -16.0527 0.1250 -7.0450 -0.2126 -4.8849 85.6364 65.3826 33.3134 -17.2827 8.4377 -6.4442 -0.1027 -3.7384 -39.9354 -15.6904 30.2180 9.2577 4.1787 -2.2267 2.9812 2.4027 2.5924 -13.6623 -5.4940 -7.8364 3.6032 2.0654 1.9024 -1.0399 2.3750 4.8097 8.6232 -5.1047 -5.6250 0.9445 0.8930 0.3232 2.9945 -3.2131 -0.8315 6.9848 4.8601 0.3043 -1.6718 1.9621 1.2530 -0.0697 0.7312 -0.2981 1.9222 2.9600 -0.7180 -2.5778 2.9642 0.1810 -0.3388 -2.6802 0.8737 -1.0296 -2.5350 -1.8505 >> J(9:16,9:16) ans = 765.7500 -337.8517 15.4053 44.1097 -3.0000 3.1585 -0.6985 2.7715 93.1163 -12.7923 -105.2548 6.4951 21.3826 -6.4124 -5.7623 -1.4411 3.9429 29.0674 5.5570 -20.2654 8.7304 15.5683 -4.3624 -6.9161 6.3625 -0.4752 -3.8135 1.3667 -8.5273 -3.2138 1.0229 2.4084 -4.7500 5.8781 -0.2078 -5.6255 -0.5000 3.6717 -1.8081 -3.3458 5.5093 -0.4890 -0.0957 -0.4586 -0.3461 -1.6795 0.1375 1.1942 -0.2802 0.6512 1.8876 -2.0940 0.1721 -0.2394 -0.8070 -0.5737 0.1225 1.8141 1.4955 -0.7570 -1.3032 -0.4243 -1.4556 0.1052
  • 13. Why Shift data? • Because the DCT is designed to work on pixel values ranging from -128 to 127, the original block is “leveled off” by subtracting 128 from each entry.
  • 14.
  • 15. With shifting DC component becomes negative dct2(int16(I(17:24,17:24))-128) ans = -257.2500 113.9048 190.8229 -14.2258 -31.7500 -26.0361 -7.0623 2.5148 -2.2054 -19.3567 26.7378 49.5825 18.4131 11.2723 -8.1334 -1.2940 -3.0683 -6.7897 -8.6176 -2.1773 0.6929 2.1958 0.9660 -1.2293 2.3132 3.9376 3.2723 8.6746 4.5256 2.9021 1.4571 1.7553 0 1.4061 -3.0190 -1.6145 1.5000 1.3845 -0.1025 -2.3183 -0.8553 -1.8905 2.8431 0.5789 3.0710 -1.4592 0.0228 -1.5351 -4.1410 2.3969 2.2160 2.8282 -0.2870 -0.1222 -0.1324 1.9538 1.8516 1.3828 -0.3954 2.7004 0.8187 1.7177 -0.6069 -1.3586 K>> dct2(int16(I(17:24,17:24))) ans = 766.7500 113.9048 190.8229 -14.2258 -31.7500 -26.0361 -7.0623 2.5148 -2.2054 -19.3567 26.7378 49.5825 18.4131 11.2723 -8.1334 -1.2940 -3.0683 -6.7897 -8.6176 -2.1773 0.6929 2.1958 0.9660 -1.2293 2.3132 3.9376 3.2723 8.6746 4.5256 2.9021 1.4571 1.7553 0 1.4061 -3.0190 -1.6145 1.5000 1.3845 -0.1025 -2.3183 -0.8553 -1.8905 2.8431 0.5789 3.0710 -1.4592 0.0228 -1.5351 -4.1410 2.3969 2.2160 2.8282 -0.2870 -0.1222 -0.1324 1.9538 1.8516 1.3828 -0.3954 2.7004 0.8187 1.7177 -0.6069 -1.3586