What is per-pixel mean?
4 次查看(过去 30 天)
显示 更早的评论
To train the CNN, RGB images(in some cases color-ROI) are preprocessed by resizing it to the smallest dimension to 256, and then we crop center 256*256 region. After this per-pixel mean(across all the image) is subtracted.
I don't get a proper sense of this concept. Is there anyone can explain?
0 个评论
采纳的回答
Walter Roberson
2016-6-27
You have a whole series of extracted images that are the same size. The per-pixel mean over the images is the mean across all the pixels for any one fixed location. So for example if the extract images are stored in AllImages,
mean(AllImages(17, 38, :))
would be the per-pixel mean for location (17, 38)
You can do this all at one time for the pixels by using
mean(AllImages, 3)
where the 3 indicates the third dimension, provided that the different images are stored as having a different third-dimensional coordinate in the array.
0 个评论
更多回答(1 个)
Image Analyst
2016-6-26
The image is resized to 256 rows or columns, along whichever dimension is smallest. The size of the other dimension is not given by you - it may also be 256, or it may be something such that the aspect ratio of the image stays the same, or it maybe something else. Regardless, you have a square or rectangular image that's 256 wide along some dimension and then it extracts the middle 256-by-256 square from that rectangular image. For example, the image is originally 480-by-640. Then it's resized to 256 by 640 (or whatever). Then the middle 256-by-256 image is extracted, essentially from row 128 to 384. Now you have a 256-by-256 square image. Then subtract the mean.
% Resize image
[rows, columns, numberOfColorChannels) = size(originalImage); % Get starting dimensions.
resizedImage = imresize(originalImage, [256, columns]);
% Extract middle 256 chunk.
col1 = columns - 128
col2 = col1 + 127
croppedImage = resizedImage(:, col1:col2);
% Compute mean of extracted chunk.
theMean = mean2(croppedImage)
% Subtract mean from the cropped image.
finalImage = croppedImage - theMean; % For grayscale only.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Get Started with Statistics and Machine Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!