Update pages/Life_cycle_of_ML.py
Browse files- pages/Life_cycle_of_ML.py +17 -13
pages/Life_cycle_of_ML.py
CHANGED
|
@@ -513,6 +513,7 @@ def More():
|
|
| 513 |
)
|
| 514 |
grayscale_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
| 515 |
hsv_image = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
|
|
|
|
| 516 |
|
| 517 |
st.code("""
|
| 518 |
# Convert to Grayscale
|
|
@@ -525,6 +526,7 @@ def More():
|
|
| 525 |
# Display color space conversions
|
| 526 |
st.image(grayscale_image, caption="Grayscale Image", channels="GRAY")
|
| 527 |
st.image(cv2.cvtColor(hsv_image, cv2.COLOR_BGR2HSV), caption="HSV Image")
|
|
|
|
| 528 |
|
| 529 |
st.code("""
|
| 530 |
# Display Grayscale and HSV Images
|
|
@@ -534,8 +536,8 @@ def More():
|
|
| 534 |
|
| 535 |
# Split and Merge Channels
|
| 536 |
st.subheader("3. Color Space Techniques")
|
| 537 |
-
st.
|
| 538 |
-
"Techniques include splitting color channels and manipulating them. Below, we split the image into Red, Green, and Blue channels."
|
| 539 |
)
|
| 540 |
b, g, r = cv2.split(image)
|
| 541 |
merged_image = cv2.merge((b,g,r))
|
|
@@ -544,8 +546,16 @@ def More():
|
|
| 544 |
# Split and Merge Channels
|
| 545 |
b, g, r = cv2.split(image)
|
| 546 |
merged_image = cv2.merge((r, g, b))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 547 |
""", language="python")
|
| 548 |
|
|
|
|
| 549 |
# Set the green and red channels to zero to keep only the blue channel
|
| 550 |
b_only = cv2.merge((b, g*0, r*0))
|
| 551 |
|
|
@@ -555,22 +565,15 @@ def More():
|
|
| 555 |
# Set the blue and green channels to zero to keep only the red channel
|
| 556 |
r_only = cv2.merge((b*0, g*0, r))
|
| 557 |
|
| 558 |
-
|
| 559 |
|
| 560 |
# Display the individual channels and manipulated images
|
| 561 |
st.image(b_only, caption="Red Channel Only")
|
| 562 |
st.image(g_only, caption="Green Channel Only")
|
| 563 |
st.image(r_only, caption="Blue Channel Only")
|
| 564 |
|
| 565 |
-
st.image(merged_image_rgb, caption="Merged Image (RGB to BGR)")
|
| 566 |
|
| 567 |
-
|
| 568 |
-
# Display individual channels and manipulated image
|
| 569 |
-
st.image(b, caption="Blue Channel", use_column_width=True, channels="GRAY")
|
| 570 |
-
st.image(g, caption="Green Channel", use_column_width=True, channels="GRAY")
|
| 571 |
-
st.image(r, caption="Red Channel", use_column_width=True, channels="GRAY")
|
| 572 |
-
""", language="python")
|
| 573 |
-
|
| 574 |
st.write("These operations help in extracting and analyzing features from images!")
|
| 575 |
|
| 576 |
# Additional Content: Thresholding
|
|
@@ -578,8 +581,9 @@ def More():
|
|
| 578 |
st.markdown("Thresholding is used to segment images by converting them into binary forms.By using `cv2.threshold` ")
|
| 579 |
_, binary_image = cv2.threshold(grayscale_image, 127, 255, cv2.THRESH_BINARY)
|
| 580 |
|
| 581 |
-
st.code("""
|
| 582 |
-
|
|
|
|
| 583 |
|
| 584 |
# Function: cv2.threshold
|
| 585 |
# Definition: Applies a fixed-level threshold to an image, converting it into a binary image.
|
|
|
|
| 513 |
)
|
| 514 |
grayscale_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
| 515 |
hsv_image = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
|
| 516 |
+
convert_color = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
| 517 |
|
| 518 |
st.code("""
|
| 519 |
# Convert to Grayscale
|
|
|
|
| 526 |
# Display color space conversions
|
| 527 |
st.image(grayscale_image, caption="Grayscale Image", channels="GRAY")
|
| 528 |
st.image(cv2.cvtColor(hsv_image, cv2.COLOR_BGR2HSV), caption="HSV Image")
|
| 529 |
+
st.image(cv2.cvtColor(convert_color, cv2.COLOR_BGR2RGB), caption="Convert_color Image")
|
| 530 |
|
| 531 |
st.code("""
|
| 532 |
# Display Grayscale and HSV Images
|
|
|
|
| 536 |
|
| 537 |
# Split and Merge Channels
|
| 538 |
st.subheader("3. Color Space Techniques")
|
| 539 |
+
st.markdown(
|
| 540 |
+
"Techniques include splitting color channels and manipulating them. Below, we split the image into Red, Green, and Blue channels. Using `cv2.split()` and combining all the colors using using `cv2.merge()`"
|
| 541 |
)
|
| 542 |
b, g, r = cv2.split(image)
|
| 543 |
merged_image = cv2.merge((b,g,r))
|
|
|
|
| 546 |
# Split and Merge Channels
|
| 547 |
b, g, r = cv2.split(image)
|
| 548 |
merged_image = cv2.merge((r, g, b))
|
| 549 |
+
""", language="python")
|
| 550 |
+
|
| 551 |
+
st.code("""
|
| 552 |
+
# Display individual channels and manipulated image
|
| 553 |
+
st.image(b, caption="Blue Channel", use_column_width=True, channels="GRAY")
|
| 554 |
+
st.image(g, caption="Green Channel", use_column_width=True, channels="GRAY")
|
| 555 |
+
st.image(r, caption="Red Channel", use_column_width=True, channels="GRAY")
|
| 556 |
""", language="python")
|
| 557 |
|
| 558 |
+
|
| 559 |
# Set the green and red channels to zero to keep only the blue channel
|
| 560 |
b_only = cv2.merge((b, g*0, r*0))
|
| 561 |
|
|
|
|
| 565 |
# Set the blue and green channels to zero to keep only the red channel
|
| 566 |
r_only = cv2.merge((b*0, g*0, r))
|
| 567 |
|
| 568 |
+
|
| 569 |
|
| 570 |
# Display the individual channels and manipulated images
|
| 571 |
st.image(b_only, caption="Red Channel Only")
|
| 572 |
st.image(g_only, caption="Green Channel Only")
|
| 573 |
st.image(r_only, caption="Blue Channel Only")
|
| 574 |
|
|
|
|
| 575 |
|
| 576 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 577 |
st.write("These operations help in extracting and analyzing features from images!")
|
| 578 |
|
| 579 |
# Additional Content: Thresholding
|
|
|
|
| 581 |
st.markdown("Thresholding is used to segment images by converting them into binary forms.By using `cv2.threshold` ")
|
| 582 |
_, binary_image = cv2.threshold(grayscale_image, 127, 255, cv2.THRESH_BINARY)
|
| 583 |
|
| 584 |
+
st.code("""
|
| 585 |
+
_, binary_image = cv2.threshold(grayscale_image, 127, 255, cv2.THRESH_BINARY)
|
| 586 |
+
print(binary_image)""",language="python")
|
| 587 |
|
| 588 |
# Function: cv2.threshold
|
| 589 |
# Definition: Applies a fixed-level threshold to an image, converting it into a binary image.
|