Spaces:
Sleeping
Sleeping
Update pages/7_Unstructured_data.py
Browse files186 unmodified lines187188189190191192186 unmodified lines- Where 2D, 3D array data type should be unsigned int8''')186 unmodified lines187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255186 unmodified lines- Where 2D, 3D array data type should be unsigned int8''')st.subheader('**Handling Images with OpenCV**')st.markdown("""Handling images involves tasks like reading, displaying, resizing, and modifying images.**Example: Loading and Displaying an Image**```pythonimport cv2img = cv2.imread('image.jpg')cv2.imshow('Loaded Image', img)cv2.waitKey()cv2.destroyAllWindows()```""")st.subheader("**Basic Code**")st.markdown("""Below is an example demonstrating fundamental OpenCV operations.The code reads an image, resizes it and then displays and saves the final image.""", unsafe_allow_html=True)st.markdown("""**1. Read the image**import cv2image = cv2.imread('path') # Provide the path to your imageif image is None:print("Error: Image not found")exit()**2. Display the original image**```pythoncv2.imshow('Original Image', image)cv2.waitKey() # It adds the delay and closes the window when a key is givencv2.destroyAllWindows()```**3. Resize the image to 200x200 pixels**```pythonresized_image = cv2.resize(image, (200, 200))```**4. Save the loaded image**```pythoncv2.imwrite('output_image.jpg',image)print("Image saved successfully!")```""", unsafe_allow_html=True)st.markdown("""<h4 style='color:#FFA500;'> Code Explanation</h4>- **Step 1: Reading the Image**: `cv2.imread()` loads the image from the specified file path. If the file is not found, the script will terminate with an error message.- **Step 2: Displaying the Original Image**: `cv2.imshow()` displays the original image in a window. The window will remain open until a key is pressed.- **Step 3: Resizing the Image**: `cv2.resize()` resizes the image to specified dimensions (in this case, 200x200 pixels)- **Step 4: Saving the Loaded Image**: `cv2.imwrite()` saves the final loaded image to a file.By following these steps, you can perform common image operations""", unsafe_allow_html=True)
pages/7_Unstructured_data.py+63