File size: 28,158 Bytes
242038e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1f95e93
 
242038e
1f95e93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242038e
1f95e93
 
242038e
1f95e93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242038e
1f95e93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0aa00cf
1f95e93
 
 
 
 
242038e
1f95e93
 
 
 
 
 
 
 
 
242038e
1f95e93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242038e
1f95e93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242038e
1f95e93
e6f9a5f
1f95e93
 
 
 
 
 
 
 
 
 
e6f9a5f
1f95e93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e6f9a5f
1f95e93
 
 
 
 
 
 
e6f9a5f
1f95e93
 
 
 
 
 
 
e6f9a5f
1f95e93
 
 
 
 
 
 
e6f9a5f
1f95e93
 
 
 
 
 
 
 
e6f9a5f
1f95e93
 
e6f9a5f
1f95e93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e6f9a5f
1f95e93
 
 
 
 
 
 
e6f9a5f
1f95e93
 
 
 
 
 
 
e6f9a5f
1f95e93
 
 
 
 
 
 
e6f9a5f
1f95e93
 
 
 
 
 
 
 
fdfbba3
1f95e93
 
 
 
 
 
 
 
 
 
fdfbba3
1f95e93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
import streamlit as st
import pandas as pd
import numpy as np

# Custom CSS for styling
custom_css = """
<style>
    html, body, [data-testid="stAppViewContainer"] {
        background-image: linear-gradient(
            rgba(0, 0, 0, 0.6), 
            rgba(0, 0, 0, 0.6)
        ), 
        url("https://www.istockphoto.com/photo/tech-or-space-background-abstract-3d-illustration-gm1367865109-437999705?utm_source=pixabay&utm_medium=affiliate&utm_campaign=SRP_photo_sponsored&utm_content=https%3A%2F%2Fpixabay.com%2Fphotos%2Fsearch%2Fbackground%2520datascience%2F&utm_term=background+datascience.jpg");
        background-size: cover;
        background-position: center;
        background-repeat: no-repeat;
        background-attachment: fixed;
        color: white;  /* Ensures all text is readable */
    }
    h2, h3 {
        color: #FFD700; /* Gold color for headings */
    }
    p {
        color: #FFFFFF; /* White text for paragraphs */
    }
    .stButton>button {
        background-color: #4CAF50; /* Green */
        color: white;
        padding: 10px 24px;
        border: none;
        border-radius: 5px;
        text-align: center;
        font-size: 16px;
        margin: 4px 2px;
        transition-duration: 0.4s;
        cursor: pointer;
    }
    .stButton>button:hover {
        background-color: #45a049; /* Darker Green on hover */
        color: white;
    }
    .stButton>div:nth-child(1)>button {
        background-color: #2196F3; /* Blue */
    }
    .stButton>div:nth-child(2)>button {
        background-color: #f44336; /* Red */
    }
    .stButton>div:nth-child(3)>button {
        background-color: #FF9800; /* Orange */
    }
</style>
"""

# Inject the CSS into the app
st.markdown("<div class='title'>Introduction to Image Data πŸ“Š</div>", unsafe_allow_html=True)
    
st.markdown(
    """
    <div class="section">
        <div class="header">What is an Image?</div>
        <div class="content">An image is a visual representation of something, such as a person, object, scene, or concept.
        It can be created using various means and exists in different forms.<br>
        The image is a 2D grid like structure where every grid represents a pixel and each pixel has its own features. <br>
        The features in a pixel include theinformation like shape, color, pattern etc.<br>
        The clarity of an image directly depends on the number of pixels it has. <br>
        Every array cannot be an image. An array can be an image only when:<br>
        1) It should be in 2D or 3D representation.<br>
        2) The datatype should only be an integer.
        </div>
    </div>
    <div class="section">
        <div class="header">What are Color Spaces?</div>
        <div class="content">
        Color Space is a technique by which we can represent the colors of an image.<br>
        There are 3 types of color spaces namely:<br>
        1) Black & White Color Space
        2) Grayscale Color Space
        3) RGB  Color Space
        </div>
    </div>
    <div class="section">
        <div class="header">Black & White Color Space</div>
        <div class="content">
        In this Color Space, there are only 2 colors to represent the image which are black & white.<br>
        Here, 0 represents black and 1 represents white.
        </div>
    </div>
    <div class="section">
        <div class="header">Grayscale Color Space</div>
        <div class="content">
        In this Color Space, we have black, white and multiple shades of gray to represent the image.<br>
        Here, 0 represents black, 255 represents white, and 1 to 254 represent various shades of gray.
        </div>
    </div>
    <div class="section">
        <div class="header">RGB Color Space</div>
        <div class="content">
        In this Color Space, we create a 3D structure with three 2D channels namely blue, green and red channels
        where 0 represents absense of color and 255 represents presense of color.<br>
        These 3 channels are stacked one after the another like a layered structure.<br>
        The blue channel has 0 which represents black, 255 which represents blue and 1 to 254 represent multiple shades of blue.<br>
        The green channel has 0 which represents black, 255 which represents green and 1 to 254 represent multiple shades of green.<br>
        The red channel has 0 which represents black, 255 which represents red and 1 to 254 represent multiple shades of red.<br>
        </div><br><br>
    </div>
    """,
    unsafe_allow_html=True,
)
if st.button("Next Page: Basic operations on an Image"):
        st.session_state['page'] = 'image_operations'

if page == 'image_operations':
    st.markdown("<div class='title'>Basic Operations on an Image</div>", unsafe_allow_html=True)
    st.markdown(
        """
        <div class="section">
            <div class="header">Operations on image  data</div>
            <div class="content">There are 3 major operations which can be performed on an image namely:<br>
            1) Reading an image<br>
            2) Writing an image<br>
            3) Showing an image
            </div>
        <div class="section">
            <div class="header">Reading an image</div>
            <div class="content">
            For this operation, we have to import <code>cv2</code> module and use the method <code>imread()</code>. 
            The method <code>imread()</code> is used to convert an image file into a numpy array.
            </div>
        </div>
        <div class="section">
            <div class="header">Writing an image</div>
            <div class="content">
            For this operation, we have to import <code>cv2</code> module and use the method <code>imwrite()</code>. 
            The method <code>imwrite()</code> is used to convert a numpy array back into an image file.
            </div>
        </div>
        <div class="section">
            <div class="header">Showing an image</div>
            <div class="content">
            For this operation, we have to import <code>cv2</code> module and use the method <code>imshow()</code>. 
            The method <code>imshow()</code> is used to display an array in the form of an image by creating a popup window. 
            </div>
        </div><br><br>
        """,
        unsafe_allow_html=True,
    )
    col1, col2 = st.columns(2)
    with col1:
        if st.button("Open Jupyter Notebook"):
            st.session_state['jupyter_clicked'] = True
            st.session_state['pdf_clicked'] = False
    with col2:
        if st.button("Open PDF"):
            st.session_state['pdf_clicked'] = True
            st.session_state['jupyter_clicked'] = False

    if st.session_state['jupyter_clicked']:
        st.markdown(
            """
            <div class="section">
                <div class="header">Jupyter Notebook for Basic Operations on an Image </div>
                <div class="content">This Jupyter notebook explains the basic operations that can be performed on an image.</div>
            </div>
            """,
            unsafe_allow_html=True,
        )
        # Embed the converted HTML file for the notebook
        notebook_html_path = "pages/basic_img_ops.html"
        with open(notebook_html_path, "r") as f:
            notebook_html = f.read()
        st.components.v1.html(notebook_html, height=500, scrolling=True)
        
    elif st.session_state['pdf_clicked']:
        st.markdown(
            """
            <div class="section">
                <div class="header">PDF file for Basic Operations on an Image</div>
                <div class="content">This PDFfile explains the basic operations that can be performed on an image.</div>
            </div>
            """,
            unsafe_allow_html=True,
        )
        
        pdf_path = "pages/basic_img_ops.pdf"
        
        # Read the PDF file content (binary data)
        with open(pdf_path, "rb") as file:
            pdf_data = file.read()  # This is the binary data of the PDF file

        # Display the PDF in an iframe
        st.markdown(
            f'<iframe src="data:application/pdf;base64,{base64.b64encode(pdf_data).decode()}" width="100%" height="600px"></iframe>',
            unsafe_allow_html=True,
        )

        # Provide download option for the PDF file
        st.download_button(
            label="Download PDF",
            data=pdf_data,  # Provide the binary file data here
            file_name="basic_img_ops.pdf",  # This is the name that will appear when the user downloads the file
            mime="application/pdf"
        )
    if st.button("Next Page: Working on the Image"):
        st.session_state['page'] = 'image_working'

elif page == 'image_working':
    st.markdown("<div class='title'>Working on the Image</div>", unsafe_allow_html=True)
    st.markdown(
        """
        <div class="section">
            <div class="header">Understanding split() method</div>
            <div class="content">
            For this operation, we have to import <code>cv2</code> module and use the method <code>split()</code>.<br><br>
            The <code>split()</code> method is used to separate a multi-channel image into its individual single-channel components.<br>
            </div>
        <div class="section">
            <div class="header">Understanding merge() method</div>
            <div class="content">
            For this operation, we have to import <code>cv2</code> module and use the method <code>merge()</code>.<br><br> 
            The <code>merge()</code> method is used to combine multiple single-channel images into a single multi-channel image.<br><br>
            </div>
        </div><br><br>
        """,
        unsafe_allow_html=True,
    )
    col1, col2 = st.columns(2)
    with col1:
        if st.button("Open Jupyter Notebook"):
            st.session_state['jupyter_clicked'] = True
            st.session_state['pdf_clicked'] = False
    with col2:
        if st.button("Open PDF"):
            st.session_state['pdf_clicked'] = True
            st.session_state['jupyter_clicked'] = False

    if st.session_state['jupyter_clicked']:
        st.markdown(
            """
            <div class="section">
                <div class="header">Jupyter Notebook for Basic Operations on an Image </div>
                <div class="content">This Jupyter notebook explains the split and merge methods that can be performed on an image.</div>
            </div>
            """,
            unsafe_allow_html=True,
        )
        # Embed the converted HTML file for the notebook
        notebook_html_path = "pages/working_on_img.html"
        with open(notebook_html_path, "r") as f:
            notebook_html = f.read()
        st.components.v1.html(notebook_html, height=500, scrolling=True)
        
    elif st.session_state['pdf_clicked']:
        st.markdown(
            """
            <div class="section">
                <div class="header">PDF file for Basic Operations on an Image</div>
                <div class="content">This PDF file explains the split and merge methods that can be performed on an image.</div>
            </div>
            """,
            unsafe_allow_html=True,
        )
        
        pdf_path = "pages/working_on_img.pdf"
        
        # Read the PDF file content (binary data)
        with open(pdf_path, "rb") as file:
            pdf_data = file.read()  # This is the binary data of the PDF file

        # Display the PDF in an iframe
        st.markdown(
            f'<iframe src="data:application/pdf;base64,{base64.b64encode(pdf_data).decode()}" width="100%" height="600px"></iframe>',
            unsafe_allow_html=True,
        )

        # Provide download option for the PDF file
        st.download_button(
            label="Download PDF",
            data=pdf_data,  # Provide the binary file data here
            file_name="working_on_img.pdf",  # This is the name that will appear when the user downloads the file
            mime="application/pdf"
        )
    if st.button("Next Page: Conversion between Color Spaces"):
        st.session_state['page'] = 'color_space_conversion_on_img'

elif page == 'color_space_conversion_on_img':
    st.markdown("<div class='title'>Conversion between Color Spaces</div>", unsafe_allow_html=True)
    st.markdown(
        """
        <div class="section">
            <div class="header">How to convert one color space to another?</div>
            <div class="content">
            In the <code>cv2</code> module, we have an in-built method called <code>cvtColor()</code> 
            along with in-built parameters for each conversion.<br><br>
            1) For converting BGR to Grayscale, 
            We use the parameter <code>COLOR_BGR2GRAY</code> inside the <code>cvtColor()</code> method.<br><br>
            2) For converting Grayscale to BGR, 
            We use the parameter <code>COLOR_GRAY2BGR</code> inside the <code>cvtColor()</code> method.<br><br>
            3) For converting BGR to RGB, 
            We use the parameter <code>COLOR_BGR2RGB</code> inside the <code>cvtColor()</code> method.<br><br>
            </div>
        </div><br><br>
        """,
        unsafe_allow_html=True,
    )
    col1, col2 = st.columns(2)
    with col1:
        if st.button("Open Jupyter Notebook"):
            st.session_state['jupyter_clicked'] = True
            st.session_state['pdf_clicked'] = False
    with col2:
        if st.button("Open PDF"):
            st.session_state['pdf_clicked'] = True
            st.session_state['jupyter_clicked'] = False

    if st.session_state['jupyter_clicked']:
        st.markdown(
            """
            <div class="section">
                <div class="header">Jupyter Notebook for Basic Operations on an Image </div>
                <div class="content">This Jupyter notebook explains the split and merge methods that can be performed on an image.</div>
            </div>
            """,
            unsafe_allow_html=True,
        )
        # Embed the converted HTML file for the notebook
        notebook_html_path = "pages/converting_color_spaces.html"
        with open(notebook_html_path, "r") as f:
            notebook_html = f.read()
        st.components.v1.html(notebook_html, height=500, scrolling=True)
        
    elif st.session_state['pdf_clicked']:
        st.markdown(
            """
            <div class="section">
                <div class="header">PDF file for Basic Operations on an Image</div>
                <div class="content">This PDF file explains the split and merge methods that can be performed on an image.</div>
            </div>
            """,
            unsafe_allow_html=True,
        )
        
        pdf_path = "pages/converting_color_spaces.pdf"
        
        # Read the PDF file content (binary data)
        with open(pdf_path, "rb") as file:
            pdf_data = file.read()  # This is the binary data of the PDF file

        # Display the PDF in an iframe
        st.markdown(
            f'<iframe src="data:application/pdf;base64,{base64.b64encode(pdf_data).decode()}" width="100%" height="600px"></iframe>',
            unsafe_allow_html=True,
        )

        # Provide download option for the PDF file
        st.download_button(
            label="Download PDF",
            data=pdf_data,  # Provide the binary file data here
            file_name="converting_color_spaces.pdf",  # This is the name that will appear when the user downloads the file
            mime="application/pdf"
        )
    if st.button("Next Page: Affine Transformations on an Image"):
        st.session_state['page'] = 'affine_transformations'

elif page == 'affine_transformations':
    st.markdown("<div class='title'>Affine Transformations on an Image</div>", unsafe_allow_html=True)
    st.markdown(
        """
        <div class="section">
            <div class="header">What are Affine Transformations?</div>
            <div class="content">
            Affine Transformations are a part of Image augmentation.<br>
            Image augmentation is a technique of creating new images from the existing images.<br>
            This technique is used to create a balance in the dataset.<br>
            For a particular label, ff there are less images compared to the other label,
            we increase the no. of images in that label using Image augmentation.<br><br>
            Advantages of Affine Transformations include:<br>
            1) We convert our imbalanced data into balanced data.<br>
            2) We get new images from old ones<br><br>
            </div>
            <div class="header">Types of Affine Transformations?</div>
            <div class="content">
            There are 5 types of Affine Transformations namely:<br>
                1) Translation<br>
                2) Rotation<br>
                3) Scaling<br>
                4) Shearing<br>
                5) Cropping<br><br>
            </div>
            <div class="header">Translation</div>
            <div class="content">
            It is a technique of shifting the image by some bits on the X-axis and the Y-axis.<br>
            The extra bits created are replaced with black color or duplicate pixels.<br>
            We apply a Translation matrix ( Tm ) for this.<br>
            </div>
            <div class="header">Rotation</div>
            <div class="content">
            It is a technique of rotating the image by at an angle from the specified position.<br>
            We apply a Rotation matrix ( Rm ) for this.<br>
            We can use a combination of Rotation & Translation in the same Rotation matrix ( Rm )<br>
            </div>
            <div class="header">Scaling</div>
            <div class="content">
            It is a technique of increasing or decreasing the size of the image by a particular scale.<br>
            We apply a Scaling matrix ( Sm ) for this.<br>
            We can use a combination of Scaling & Translation in the same Scaling matrix ( Sm )<br>
            </div>
            <div class="header">Shearing</div>
            <div class="content">
            It is a technique of stretching the image from its edges by a particular value.<br>
            We apply a Shearing matrix ( Shm ) for this.<br>
            We can use a combination of Shearing, Scaling & Translation in the same Shearing matrix ( Shm )<br>
            </div>
            <div class="header">Cropping</div>
            <div class="content">
            It is a technique of extracting or cutting a part of the image from the original image.<br>
            We don't have a cropping matrix for this  technique.<br>
            Instead, we have to do it manually using slicing operation on the Numpy array.<br>
            </div>
        </div><br><br>
        """,
        unsafe_allow_html=True,
    )
    col1, col2 = st.columns(2)
    with col1:
        if st.button("Open Jupyter Notebook"):
            st.session_state['jupyter_clicked'] = True
            st.session_state['pdf_clicked'] = False
    with col2:
        if st.button("Open PDF"):
            st.session_state['pdf_clicked'] = True
            st.session_state['jupyter_clicked'] = False

    if st.session_state['jupyter_clicked']:
        st.markdown(
            """
            <div class="section">
                <div class="header">Jupyter Notebook for Basic Operations on an Image </div>
                <div class="content">This Jupyter notebook explains all the affine transformations that can be performed on an image.</div>
            </div>
            """,
            unsafe_allow_html=True,
        )
        # Embed the converted HTML file for the notebook
        notebook_html_path = "pages/affine_transformations.html"
        with open(notebook_html_path, "r") as f:
            notebook_html = f.read()
        st.components.v1.html(notebook_html, height=500, scrolling=True)
        
    elif st.session_state['pdf_clicked']:
        st.markdown(
            """
            <div class="section">
                <div class="header">PDF file for Basic Operations on an Image</div>
                <div class="content">This PDF file explains all the affine transformations that can be performed on an image.</div>
            </div>
            """,
            unsafe_allow_html=True,
        )
        
        pdf_path = "pages/affine_transformations.pdf"
        
        # Read the PDF file content (binary data)
        with open(pdf_path, "rb") as file:
            pdf_data = file.read()  # This is the binary data of the PDF file

        # Display the PDF in an iframe
        st.markdown(
            f'<iframe src="data:application/pdf;base64,{base64.b64encode(pdf_data).decode()}" width="100%" height="600px"></iframe>',
            unsafe_allow_html=True,
        )

        # Provide download option for the PDF file
        st.download_button(
            label="Download PDF",
            data=pdf_data,  # Provide the binary file data here
            file_name="affine_transformations.pdf",  # This is the name that will appear when the user downloads the file
            mime="application/pdf"
        )
    if st.button("Next Page: Handling Video Data"):
        st.session_state['page'] = 'video_data'

elif page == 'video_data':
    st.markdown("<div class='title'>Handling Video Data</div>", unsafe_allow_html=True)
    st.markdown(
        """
        <div class="section">
            <div class="header">What is a Video?</div>
            <div class="content">
            A video is a sequence of images, called frames, displayed rapidly one after another to create the illusion of motion.<br><br>
            To deal with the video data, we import the <code>cv2</code> module and use the <code>VideoCapture()</code> method.<br><br>
            <code>VideoCapture()</code> method is used to converts a video into list of frames.<br><br>
            </div>
            <div class="header">Playing the Video</div>
            <div class="content">
            If we specify a path inside <code>VideoCapture()</code> method, it reads the particular video.<br><br>
            </div>
            <div class="header">Live Video capturing</div>
            <div class="content">
            If we assign 0 inside the <code>VideoCapture()</code> method, it open the Web camera for live video capturing.<br><br>
        </div><br><br>
        """,
        unsafe_allow_html=True,
    )
    col1, col2 = st.columns(2)
    with col1:
        if st.button("Open Jupyter Notebook"):
            st.session_state['jupyter_clicked'] = True
            st.session_state['pdf_clicked'] = False
    with col2:
        if st.button("Open PDF"):
            st.session_state['pdf_clicked'] = True
            st.session_state['jupyter_clicked'] = False

    if st.session_state['jupyter_clicked']:
        st.markdown(
            """
            <div class="section">
                <div class="header">Jupyter Notebook for Basic Operations on an Image </div>
                <div class="content">This Jupyter notebook explains how to handle video data.</div>
            </div>
            """,
            unsafe_allow_html=True,
        )
        # Embed the converted HTML file for the notebook
        notebook_html_path = "pages/handling_video_data.html"
        with open(notebook_html_path, "r") as f:
            notebook_html = f.read()
        st.components.v1.html(notebook_html, height=500, scrolling=True)
        
    elif st.session_state['pdf_clicked']:
        st.markdown(
            """
            <div class="section">
                <div class="header">PDF file for Basic Operations on an Image</div>
                <div class="content">This PDF file explains how to handle video data.</div>
            </div>
            """,
            unsafe_allow_html=True,
        )
        
        pdf_path = "pages/handling_video_data.pdf"
        
        # Read the PDF file content (binary data)
        with open(pdf_path, "rb") as file:
            pdf_data = file.read()  # This is the binary data of the PDF file

        # Display the PDF in an iframe
        st.markdown(
            f'<iframe src="data:application/pdf;base64,{base64.b64encode(pdf_data).decode()}" width="100%" height="600px"></iframe>',
            unsafe_allow_html=True,
        )

        # Provide download option for the PDF file
        st.download_button(
            label="Download PDF",
            data=pdf_data,  # Provide the binary file data here
            file_name="handling_video_data.pdf",  # This is the name that will appear when the user downloads the file
            mime="application/pdf"
        )
    if st.button("Next Page: Interesting projects on Image & Video data"):
        st.session_state['page'] = 'projects'

elif page == 'projects':
    st.markdown("<div class='title'>πŸŽ₯✨ Interesting Projects on Image & Video Data πŸŒŸπŸ–ΌοΈ</div>", unsafe_allow_html=True)
    st.markdown(
        """
        <div class="section">
            <div class="header">Converting an Image into Tabular data</div>
            <div class="content">
            This amazing project explains how we can convert an image into tabular data. Check this out below πŸ‘‡
            <br>
            </div>
        </div><br>
        """,
        unsafe_allow_html=True,
    )
    if st.button("Go to Project 1"):
        js = "window.open('https://github.com/ChaitanyaSubhakar/Handling-Image-and-Video/blob/main/converting_image_into_tabular_data.ipynb')"
        st.components.v1.html(f"<script>{js}</script>", height=0)
    st.markdown(
        """
        <div class="section">
            <div class="header">Converting a Video into Tabular data</div>
            <div class="content">
            This amazing project explains how we can convert a video into tabular data. Check this out below πŸ‘‡
            <br>
            </div>
        </div><br>
        """,
        unsafe_allow_html=True,
    )
    if st.button("Go to Project 2"):
        js = "window.open('https://github.com/ChaitanyaSubhakar/Handling-Image-and-Video/blob/main/converting_videos_into_tabular_data.ipynb')"
        st.components.v1.html(f"<script>{js}</script>", height=0)
    st.markdown(
        """
        <div class="section">
            <div class="header">Animation Project</div>
            <div class="content">
            This amazing project explains how we can create interesting Animation videos using OpenCV package. Check this out below πŸ‘‡
            <br>
            </div>
        </div><br>
        """,
        unsafe_allow_html=True,
    )
    if st.button("Go to Project 3"):
        js = "window.open('https://github.com/ChaitanyaSubhakar/Handling-Image-and-Video/blob/main/animation_project_opencv.ipynb')"
        st.components.v1.html(f"<script>{js}</script>", height=0)
    st.markdown(
        """
        <div class="section">
            <div class="header">GIF Project</div>
            <div class="content">
            This amazing project explains how we can create an interesting GIF using OpenCV package. Check this out below πŸ‘‡
            <br>
            </div>
        </div><br>
        """,
        unsafe_allow_html=True,
    )
    if st.button("Go to Project 4"):
        js = "window.open('https://github.com/ChaitanyaSubhakar/Handling-Image-and-Video/blob/main/GIF_project.ipynb')"
        st.components.v1.html(f"<script>{js}</script>", height=0)
    st.markdown(
        """
        <div class="section">
            <div class="header">Cropping Tool</div>
            <div class="content">
            This amazing project explains how we can create an interesting GIF using OpenCV package. Check this out below πŸ‘‡
            <br>
            </div>
        </div><br>
        """,
        unsafe_allow_html=True,
    )
    if st.button("Go to Project 5"):
        js = "window.open('https://github.com/ChaitanyaSubhakar/Handling-Image-and-Video/blob/main/cropping_tool.ipynb')"
        st.components.v1.html(f"<script>{js}</script>", height=0)
    if st.button("Return to main page.."):
        st.session_state['page'] = 'unstructured_data'