Feb-21-2024, 11:15 AM
(This post was last modified: Feb-21-2024, 04:37 PM by deanhystad.)
Trying to retrieve data from images using four modules.
This is the error message:
Is there something I should put before this code, like you do in HTML ?
I also wonder where the output of this would be. I´ve just copy pasted it, and never used Python before.
This is the error message:
Error:>>> %Run -c $EDITOR_CONTENT
Traceback (most recent call last):
File "<string>", line 6
image = cv2.imread(“C:\Users\Audun Nilsen\Pictures\pica.webp”)
^
SyntaxError: invalid character in identifier
>>>
This is the code:import cv2 # OpenCV for image processing import NumPy as np # NumPy for numerical computations from skimage import io, feature, segmentation # Scikit-image for image processing and analysis import matplotlib.pyplot as plt # Matplotlib for visualization image = cv2.imread(“C:\Users\Audun Nilsen\Pictures\pica.webp”) # Convert to grayscale if needed gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) # Apply preprocessing techniques (e.g., resizing, noise reduction, contrast enhancement) resized_image = cv2.resize(gray, (256, 256)) edges = feature.canny(resized_image) # Edge detection segments = segmentation.slic(resized_image, n_segments=100) # Superpixel segmentation texture_features = feature.local_binary_pattern(resized_image, 8, 1) # Texture analysis edge_histogram = np.histogram(edges.ravel(), bins=256)[0] texture_histogram = np.histogram(texture_features.ravel(), bins=256)[0] # Calculate statistics (mean, median, standard deviation) across multiple images mean_edge_histogram = np.mean([edge_histogram1, edge_histogram2, …], axis=0) kmeans = KMeans(n_clusters=4) clusters = kmeans.fit_predict(texture_features) model = SVC() model.fit(training_features, training_labels) predictions = model.predict(test_features) # Use similarity measures (e.g., Euclidean distance, cosine similarity) distances = np.linalg.norm(query_features – database_features, axis=1)
Is there something I should put before this code, like you do in HTML ?
I also wonder where the output of this would be. I´ve just copy pasted it, and never used Python before.
deanhystad write Feb-21-2024, 04:37 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.