Where should we need to convert images from rgb to greyscal in image classification - neural-network

I am working with an plant disease image classifiaction, is it necessary to convert the dataset to greyscal

Related

How to extract temperature value of each pixel from thermal image

I am trying to save temperature data from infiray t2L thermal camera. The image from thermal camera includes 4 additional rows (i.e. 4x256 pixels), the original resolution of camera is (192x256). I guess that some data is stored in the additional rows of image, but the camera does not provide temperature values of pixel.
How can I decode 4 additional rows included in the image in order to get access to the temperature of each pixel using MATLAB and save it to a csv file.

Modifying an imageDatastore without restoring the images

I am using an imageDatastore containing the labels and grayscale images for a deep learning classification problem. I want to fine tune alexnet on my dataset but it accepts RGB images.
How can I modify the imageDatastore without storing them again assuming that I just want to concatenate the grayscale image in 3 channels?

classification using 4-channel images in pytorch

I have some gray scale and color images with label. I want to combine this gray and color images (4-channel) and run transfer learning using 4-channel images. How to do that?
If I understand the question correctly you want to combine 1 channel images and 3 channel images and get a 4 channel image and use this as your input.
If this is what you want to do you can just use torch.cat().
Some example code of loading two images and combining them along the channel dimension
import numpy as np
import torch
from PIL import Image
image_rgb = Image.open(path_to_rgb_image)
image_rgb_tensor = torch.from_numpy(np.array(image_rgb))
image_rgb.close()
image_grayscale = Image.open(path_to_grayscale_image))
image_grayscale_tensor = troch.from_numpy(np.array(image_grayscale))
image_grayscale.close()
image_input = torch.cat([image_rgb_tensor, image_grayscale_tensor], dim=2)
I assumed that the grayscale image you want to use translated to a tensor with the shape [..., ..., 1] and the rgb image to [..., ..., 3].
your current model expects an RGB input with only three channels, thus its first conv layer has in_channels=3 and the shape of this first layer's weight is out_channelsx3xkernel_heightxkernel_width.
In order to accommodate 4 channel input, you need to change the first layer to have in_channels=4 and a weight of shape out_channelsx4xkernel_heightxkernel_width. You also want to preserve the learned weights, so you should initialize the new weight to be the same as the old except for tiny noise in the added weights.

caffe: how to design lmdb for bounding box regression

I am trying to import the SUN RGB-D dataset into lmdb format so that caffe can train for the bounding box regression. I see for imagenet conversion, there is a file putting the filename and the class label on one row. How can I prepare the data so I can label an object by four point coordinates? There are about 10 objects recognized in the ground truth image, so one image should contain around 10 * 8 values for the regression result.

How to store the images with colourmap in MATLAB

I am using HDF satellite data to retrieve bands from that I am concluding different vegetation indices. Every band in hdf data is in grey colour format, its a grey colour scale image. After HDF data processed I can convert into colour by using colour map (I am using jet for colourmap). My doubt is how to convert greyscale image into colourmaped while using imwrite. How to use colourmap within imwrite. I have tried many times, but the output is only in full blue colour, this spoil the output image. Please help me to do this.
Why use imwrite? You can use imshow.
Example:
imshow(im)
imshow(im,'Colormap',jet(255))
With reference: http://www.alecjacobson.com/weblog/?p=1655
Try using the ind2rgb function before using imwrite if you want to save to a format like .jpg, but if you are using an indexing image format (e.g. .png) you can just use imwrite directly as shown in the docs:
imwrite(X, map, filename)
where X is your greyscale image, map is your colourmap (i.e. jet) and filename is the is the name of the image you want to save ending in .png