-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp2.html
More file actions
336 lines (297 loc) · 20.5 KB
/
p2.html
File metadata and controls
336 lines (297 loc) · 20.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Practical 2: Sampling Rate & Spatial Resolution | CSU2543</title>
<meta name="description" content="Practical 2: Impact of Sampling Rate on Spatial Resolution — Digital Image Processing Lab CSU2543. Shoolini University.">
<meta name="author" content="Divya Mohan">
<script>
(function(){var t=localStorage.getItem('dip-theme');if(!t){t=window.matchMedia&&window.matchMedia('(prefers-color-scheme:dark)').matches?'dark':'light';}document.documentElement.setAttribute('data-theme',t);})();
</script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
<link rel="stylesheet" href="./css/base.css">
<link rel="stylesheet" href="./css/components.css">
<style>
.print-only { display: none; }
@media print {
* { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
@page { margin: 0.75in 0.85in 0.75in 0.85in; }
body {
background: white !important; color: black !important;
font-family: 'Times New Roman', Times, serif !important;
font-size: 12pt !important; line-height: 1.45 !important; margin: 0 !important;
}
.dip-navbar, .theme-toggle, .skip-link, #toast, .btn-run,
.image-select, .chapter-select, select, .btn-pair, .pair-btn,
input[type="range"], .slider-group, .no-print, .site-footer,
.card-arrow, .hero-badge, .hero, .practical-grid,
.picker-bar, .image-picker, .picker-label,
label[for], input[type="radio"], .colab-badge { display: none !important; }
.print-only { display: block !important; }
.print-cover {
display: flex !important; flex-direction: column; align-items: center; justify-content: center;
min-height: 100vh; page-break-after: always; text-align: center;
padding: 0.75in 1in; font-family: 'Times New Roman', Times, serif !important; border: 3pt double black; margin: 0;
}
.print-cover .cover-logo { width: 140px; height: auto; margin-bottom: 18pt; }
.print-cover .cover-university { font-size: 20pt; font-weight: bold; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 4pt; }
.print-cover .cover-dept { font-size: 12pt; margin-bottom: 28pt; color: #222; line-height: 1.6; }
.print-cover .cover-rule { width: 60%; height: 2pt; background: black; margin: 0 auto 20pt; }
.print-cover .cover-subject { font-size: 18pt; font-weight: bold; margin-bottom: 4pt; letter-spacing: 0.03em; }
.print-cover .cover-code { font-size: 13pt; font-weight: bold; margin-bottom: 20pt; color: #333; }
.print-cover .cover-practical { font-size: 15pt; font-weight: bold; font-style: italic; margin-bottom: 32pt; padding: 8pt 24pt; border-top: 1pt solid #666; border-bottom: 1pt solid #666; }
.print-cover .cover-table { border-collapse: collapse; font-size: 12pt; margin: 0 auto; text-align: left; }
.print-cover .cover-table td { padding: 4pt 12pt; vertical-align: top; }
.print-cover .cover-table td:first-child { font-weight: bold; text-align: right; padding-right: 16pt; white-space: nowrap; }
.print-cover .cover-rule-sm { width: 25%; height: 0.75pt; background: #888; margin: 28pt auto 10pt; }
.print-cover .cover-session { font-size: 12pt; font-style: italic; color: #444; }
.container { max-width: 100% !important; padding: 0 !important; }
#main-content { padding: 0 !important; margin: 0 !important; }
h2, #main-content h2 { font-family: 'Times New Roman', Times, serif !important; font-size: 16pt !important; font-weight: bold !important; text-align: center !important; margin: 14pt 0 10pt !important; padding: 0 !important; border: none !important; display: block !important; color: black !important; }
h3, .section-card h3 { font-family: 'Times New Roman', Times, serif !important; font-size: 13pt !important; font-weight: bold !important; color: black !important; border: none !important; border-bottom: 0.5pt solid #ccc !important; padding: 0 0 3pt 0 !important; margin: 10pt 0 6pt !important; }
h4, .analysis-box h4 { font-family: 'Times New Roman', Times, serif !important; font-size: 12pt !important; font-weight: bold !important; font-style: italic !important; color: black !important; margin: 8pt 0 4pt !important; padding: 0 !important; }
.section-card { background: transparent !important; border: none !important; box-shadow: none !important; padding: 0 !important; margin-bottom: 6pt !important; }
.section-card p, p { font-size: 12pt !important; text-align: justify !important; max-width: none !important; margin-bottom: 4pt !important; line-height: 1.45 !important; }
.theory-box { background: #f7f7f7 !important; border-left: 2.5pt solid #333 !important; border-top: none !important; border-right: none !important; border-bottom: none !important; padding: 6pt 10pt !important; margin: 6pt 0 !important; font-size: 11pt !important; color: black !important; page-break-inside: avoid; }
.analysis-box { background: transparent !important; border-top: 1pt solid #ccc !important; border-bottom: none !important; border-left: none !important; border-right: none !important; padding: 6pt 0 0 !important; margin: 10pt 0 !important; page-break-inside: avoid; }
.analysis-box ol { font-size: 11pt !important; padding-left: 18pt !important; }
.analysis-box li { margin-bottom: 3pt !important; text-align: justify !important; line-height: 1.45 !important; }
.result-img { max-width: 95% !important; max-height: 8.5in !important; width: auto !important; height: auto !important; margin: 6pt auto !important; display: block !important; border: 0.5pt solid #bbb !important; border-radius: 0 !important; }
img { max-width: 100% !important; }
code { font-size: 10pt !important; background: #f5f5f5 !important; padding: 1pt 3pt !important; border: 0.5pt solid #ddd !important; font-family: 'Courier New', monospace !important; }
.print-header { display: block !important; text-align: center; font-family: 'Times New Roman', Times, serif !important; padding-bottom: 5pt; margin-bottom: 8pt; border-bottom: 0.75pt solid #999; }
.print-header .ph-line { font-size: 10pt; color: #555; letter-spacing: 0.02em; }
h2, h3, h4 { page-break-after: avoid !important; }
.ds-grid { display: grid !important; grid-template-columns: repeat(3, 1fr) !important; gap: 4pt !important; margin: 4pt 0 !important; }
.ds-item img { border-radius: 0 !important; }
.ds-label { font-size: 9pt !important; margin-top: 2pt !important; }
}
</style>
</head>
<body>
<a href="#main-content" class="skip-link">Skip to main content</a>
<nav class="navbar navbar-expand-lg sticky-top dip-navbar" id="mainNav" aria-label="Main navigation">
<div class="container">
<a class="navbar-brand fw-semibold" href="./index.html">DIP Lab</a>
<button class="navbar-toggler border-0" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ms-auto gap-1">
<li class="nav-item"><a class="nav-link" href="./index.html" data-page="index">Home</a></li>
<li class="nav-item"><a class="nav-link" href="./p1.html" data-page="p1">P1</a></li>
<li class="nav-item"><a class="nav-link" href="./p2.html" data-page="p2">P2</a></li>
<li class="nav-item"><a class="nav-link" href="./p3.html" data-page="p3">P3</a></li>
<li class="nav-item"><a class="nav-link" href="./p4.html" data-page="p4">P4</a></li>
<li class="nav-item"><a class="nav-link" href="./p5.html" data-page="p5">P5</a></li>
<li class="nav-item"><a class="nav-link" href="./p6.html" data-page="p6">P6</a></li>
<li class="nav-item"><a class="nav-link" href="./p7.html" data-page="p7">P7</a></li>
<li class="nav-item"><a class="nav-link" href="./p8.html" data-page="p8">P8</a></li>
</ul>
<button id="themeToggle" class="btn btn-sm ms-3 theme-toggle" type="button" aria-label="Toggle theme"><span class="theme-toggle-label">Dark</span></button>
</div>
</div>
</nav>
<!-- Print cover page -->
<div class="print-only print-cover" aria-hidden="true">
<img class="cover-logo" src="https://shooliniuniversity.com/assets/images/logo.png" alt="Shoolini University Logo">
<div class="cover-university">Shoolini University</div>
<div class="cover-dept">Faculty of Engineering & Technology<br>Department of Computer Science & Engineering</div>
<div class="cover-rule"></div>
<div class="cover-subject">Digital Image Processing</div>
<div class="cover-code">Course Code: CSU2543</div>
<div class="cover-practical">Practical 2: Impact of Sampling Rate on Spatial Resolution</div>
<table class="cover-table">
<tr><td>Submitted by:</td><td>Divya Mohan</td></tr>
<tr><td>Programme:</td><td>B.Tech CSE (Cybersecurity)</td></tr>
<tr><td>Semester:</td><td>8th</td></tr>
<tr><td>Faculty Guide:</td><td>Ishani Sharma</td></tr>
<tr><td>Reference Text:</td><td>Gonzalez & Woods, <em>Digital Image Processing</em>, 3rd Ed.</td></tr>
</table>
<div class="cover-rule-sm"></div>
<div class="cover-session">Academic Session 2025–2026</div>
</div>
<!-- Print running header -->
<div class="print-only print-header" aria-hidden="true">
<div class="ph-line">Shoolini University · CSU2543 · Digital Image Processing · Divya Mohan</div>
</div>
<main id="main-content">
<div class="container">
<h2>Practical 2: Impact of Sampling Rate on Spatial Resolution</h2>
<p class="no-print" style="margin-bottom:1rem"><a href="https://colab.research.google.com/github/divyamohan1993/dip-practical/blob/main/Practical_2.ipynb" target="_blank" rel="noopener"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab" style="height:20px;vertical-align:middle"></a> <span style="font-size:0.8rem;color:var(--text-muted)">Run this practical in Google Colab</span></p>
<div class="section-card">
<h3>Objective</h3>
<p>To evaluate the relationship between the sampling rate \(N\) and spatial resolution in digital images.</p>
<div class="theory-box">
<strong>Problem Statement:</strong> Spatial resolution represents the size of the smallest perceptible detail in an image and is fundamentally dependent on the sampling rate. A decrease in the number of samples \(N\) results in a loss of geometric detail. In this experiment, you will simulate progressive spatial resolution reduction and analyze the resulting artifacts.
</div>
</div>
<div class="picker-bar" id="mainPicker"></div>
<div class="section-card">
<h3>Part 1: Progressive Downsampling</h3>
<p>The image is resized to a 1024×1024 baseline, then progressively halved 5 times using area-averaging interpolation: 1024 → 512 → 256 → 128 → 64 → 32.</p>
<button class="btn-run" id="btnDownsample" disabled>Downsample Series</button>
<div id="dsSteps"></div>
</div>
<div class="section-card">
<h3>Part 2: Comparison Plot</h3>
<p>View all resolution levels in a single comparison figure.</p>
<button class="btn-run" id="btnCompare" disabled>Show Comparison</button>
<div id="comparePlot"></div>
</div>
<div class="section-card">
<h3>Part 3: Quality Loss Visualization (Upscale Back)</h3>
<p>Each downsampled image is upscaled back to 1024×1024 using bilinear interpolation, revealing quality degradation at each resolution level.</p>
<button class="btn-run" id="btnUpscale" disabled>Upscale Compare</button>
<div id="upscalePlot"></div>
</div>
<div class="analysis-box">
<h4>Analysis Questions</h4>
<ol>
<li><strong>Artifact Identification:</strong> At which resolution \(N\) do "jagged lines" (aliasing) become clearly visible to the eye? Explain how this correlates to the sampling rate and the Nyquist criterion.</li>
<li><strong>Sensitivity Analysis:</strong> Theory suggests spatial resolution is more sensitive to shape variations than lighting variations. Compare the detail in textured areas versus smooth areas; which loses perceptible detail first as \(N\) decreases?</li>
<li><strong>DPI Correlation:</strong> If the physical size of the image remains constant while the pixel count is halved, how does this affect the Dots Per Inch (DPI)? Relate this to the "blocky" appearance observed in the upscaled results.</li>
</ol>
</div>
</div>
</main>
<footer class="site-footer" aria-label="Site footer">
<div class="container">
<p>CSU2543 Digital Image Processing · Shoolini University · Divya Mohan · Ishani Sharma</p>
</div>
</footer>
<div id="toast" class="toast" role="status" aria-live="polite" aria-atomic="true"></div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
<script src="./js/core.js"></script>
<script src="./js/theme.js"></script>
<script src="./js/nav.js"></script>
<script src="./js/interactive.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js@4/dist/chart.umd.min.js"></script>
<script src="./js/dip.js"></script>
<script src="./js/plot.js"></script>
<script src="./js/picker.js"></script>
<script>
(async function() {
'use strict';
var RESOLUTIONS = [1024, 512, 256, 128, 64, 32];
var BASELINE = 1024;
var baselineGray = null;
var downsampled = [];
var picker = await DIP.createPicker('mainPicker', {
id: 'main',
defaultChapter: 'CH02',
defaultImage: 'cameraman',
onReady: function() {
document.querySelectorAll('.btn-run').forEach(function(b) { b.disabled = false; });
}
});
function getSel() {
var s = picker.getSelection();
if (!s || !s.filename) { DIP.showToast('Select an image first'); return null; }
return s;
}
function toBaseline(img) {
if (img.width === BASELINE && img.height === BASELINE) return img;
if (img.width > BASELINE || img.height > BASELINE) {
return DIP.downsample(img.gray, img.width, img.height, BASELINE, BASELINE);
}
return DIP.upscale(img.gray, img.width, img.height, BASELINE, BASELINE);
}
function buildDownsampleChain(base) {
var chain = [{ gray: base.gray, width: BASELINE, height: BASELINE }];
for (var i = 1; i < RESOLUTIONS.length; i++) {
var prev = chain[i - 1];
var nw = RESOLUTIONS[i];
var nh = RESOLUTIONS[i];
chain.push(DIP.downsample(prev.gray, prev.width, prev.height, nw, nh));
}
return chain;
}
async function loadAndPrepare() {
var sel = getSel();
if (!sel) return null;
var img = await DIP.loadImage(sel.url);
var base = toBaseline(img);
baselineGray = base;
downsampled = buildDownsampleChain(base);
return downsampled;
}
function showError(container, msg) {
var p = DIP.createEl('p', '', 'Error: ' + msg);
p.style.color = 'var(--error)';
container.textContent = '';
container.appendChild(p);
}
document.getElementById('btnDownsample').addEventListener('click', async function() {
var container = document.getElementById('dsSteps');
DIP.setLoading(container, true);
try {
var chain = await loadAndPrepare();
if (!chain) { DIP.setLoading(container, false); return; }
var panels = chain.map(function(item) {
return { type: 'image', title: item.width + ' \u00d7 ' + item.height };
});
var cells = DIP.figure(container, 'Progressive Downsampling: 1024 \u2192 32', 3, panels);
chain.forEach(function(item, idx) {
DIP.draw.gray(cells[idx].canvas, item.gray, item.width, item.height);
});
DIP.showToast('Downsampling complete');
} catch (e) {
showError(container, e.message);
}
DIP.setLoading(container, false);
});
document.getElementById('btnCompare').addEventListener('click', async function() {
var container = document.getElementById('comparePlot');
DIP.setLoading(container, true);
try {
if (!downsampled.length) {
var chain = await loadAndPrepare();
if (!chain) { DIP.setLoading(container, false); return; }
}
var panels = downsampled.map(function(item) {
return { type: 'image', title: item.width + ' \u00d7 ' + item.height };
});
var cells = DIP.figure(container, 'All Resolution Levels', 6, panels);
downsampled.forEach(function(item, idx) {
DIP.draw.gray(cells[idx].canvas, item.gray, item.width, item.height);
});
DIP.showToast('Comparison ready');
} catch (e) {
showError(container, e.message);
}
DIP.setLoading(container, false);
});
document.getElementById('btnUpscale').addEventListener('click', async function() {
var container = document.getElementById('upscalePlot');
DIP.setLoading(container, true);
try {
if (!downsampled.length) {
var chain = await loadAndPrepare();
if (!chain) { DIP.setLoading(container, false); return; }
}
var upscaled = downsampled.map(function(item) {
if (item.width === BASELINE && item.height === BASELINE) return item;
return DIP.upscale(item.gray, item.width, item.height, BASELINE, BASELINE);
});
var panels = upscaled.map(function(item, idx) {
var origRes = downsampled[idx].width;
return { type: 'image', title: origRes + ' \u2192 1024 (upscaled)' };
});
var cells = DIP.figure(container, 'Quality Loss: Downsample then Upscale to 1024\u00d71024', 3, panels);
upscaled.forEach(function(item, idx) {
DIP.draw.gray(cells[idx].canvas, item.gray, item.width, item.height);
});
DIP.showToast('Upscale comparison ready');
} catch (e) {
showError(container, e.message);
}
DIP.setLoading(container, false);
});
})();
</script>
</body>
</html>