BioAITeam / Coffee-Maturity-Classification-using-Convolutional-Neural-Networks-and-Transfer-Learning

0 stars 2 forks source link

Data problem #2

Open SHAOTAO1998 opened 10 months ago

SHAOTAO1998 commented 10 months ago

hi! How did you process an image size of 480 × 640×15 channels to 224 × 224 ×15? How to display a picture of your npy file? How to convert multispectral images into npy files?

MrMercado commented 9 months ago

hi! How did you process an image size of 480 × 640×15 channels to 224 × 224 ×15? This process can be done in several ways, we chose to resize with cv2.resize() iterating channel by channel, the following code snippet may help you:

import cv2
import numpy as np

# Function to resize an image with multiple channels
def resize_multichannel_image(image, new_size):
    # Split the image into individual channels
    channels = [image[:, :, i] for i in range(image.shape[2])]

    # Resize each channel
    resized_channels = [cv2.resize(channel, new_size) for channel in channels]

    # Combine the resized channels
    resized_image = np.stack(resized_channels, axis=2)
    return resized_image

# Resize the image
new_size = (224, 224)
resized_image = resize_multichannel_image(image, new_size)

How to display an image from your npy? file. You cannot display a 15-channel image since it is hyperdimensional, to plot it you must do it channel by channel.

How to convert multispectral images to npy? files? An image can be converted to an .npy file since it is a matrix of NxNxN, you can use np.save(image)

SHAOTAO1998 commented 9 months ago

Thank you for your answer!

I'm wondering how the tweaking code can draw a picture of the accuracy and loss function of the training set, validation set.

------------------ 原始邮件 ------------------ 发件人: "BioAITeam/Coffee-Maturity-Classification-using-Convolutional-Neural-Networks-and-Transfer-Learning" @.>; 发送时间: 2024年1月10日(星期三) 上午8:30 @.>; @.**@.>; 主题: Re: [BioAITeam/Coffee-Maturity-Classification-using-Convolutional-Neural-Networks-and-Transfer-Learning] Data problem (Issue #2)

hi! How did you process an image size of 480 × 640×15 channels to 224 × 224 ×15? This process can be done in several ways, we chose to resize with "cv2.resize()" iterating channel by channel, the following code snippet may help you:

import cv2 import numpy as np

Function to resize an image with multiple channels

def resize_multichannel_image(image, new_size):

Split the image into individual channels

channels = [image[:, :, i] for i in range(image.shape[2])]

Resize each channel resized_channels = [cv2.resize(channel, new_size) for channel in channels] # Combine the resized channels resized_image = np.stack(resized_channels, axis=2) return resized_image

Resize the image

new_size = (224, 224) resized_image = resize_multichannel_image(image, new_size)

Verify the size of the resized image

print(resized_image.shape)

How to display an image from your npy? file. You cannot display a 15-channel image since it is hyperdimensional, to plot it you must do it channel by channel.

How to convert multispectral images to npy? files? An image can be converted to an .npy file since it is a matrix of NxNxN, you can use np.save(image)

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>