Center crop and resize in compose or sequential transform

Hello! I have a question that what actually does the resize and center crop do? I have a signal image with dimensions 432x288 and I want to apply Alexnet for 28x28 size. Now I’m confused how to change size here. I tried to visualize the behavior using PyTorch documents but don’t understand it. How can I achieve a 28x28 size what should I pass here in resize and centercrop. Also what impact does compose and sequential transform have? I’m attaching my attempt:

transform = transforms.Compose([
transforms.Grayscale(1),
transforms.Resize(28),
transforms.CenterCrop(28),
transforms.ToTensor()
#transforms.Normalize(mean=[0.16592294], std=[0.31460345])
])


besides how can I visualize once resize the image and centercrop the resized one? I want to check this thing right after transform part considering my rgb image will be now grayscaled.

Try to pass the size argument as a tuple to make sure both spatial dimensions are resized.
A center crop of the same size after a resize operation should not be needed as you would just slice the entire image again without changing anything.
You could apply the transformations separately and check the intermediate outputs.

ok but can you tell me what i the difference in resize and center crop? why they both are needed as i have seen others doing both at the same time.

The resize transformation resizes the input image by interpolating values to create the desired output size.
Center crop on the other hand just crops the image from the center pixel using the specific size.
You don’t need the crop the image if the size won’t change.
Others would most likely use it for data augmentation with different sizes.