How to improve quality of resized images?

7 次查看(过去 30 天)
Hello, I made object detector using faster r-cnn ... i resized images from 1920x1080 to input size [224 224 3]... but after running detector on test image, image looks so bad :
How to improve quality of the image ?
Here is the code where i am running detector on test image :
I = imread(testDataTbl.imageFilename{84});
I = imresize(I,inputSize(1:2));
[bboxes,scores] = detect(detector,I);
I = insertObjectAnnotation(I,'rectangle',bboxes,scores);
figure
imshow(I)
  1 个评论
Walter Roberson
Walter Roberson 2023-5-9
You could try using a method option for the imresize()...
but rerducing an image by a factor of 8 1/2 in one direction and 4 3/4 in a different direction is going to reduce detail to only about 2.5% of the original, and is going to distort aspect ratios. You should not expect it to get "good" results.

请先登录,再进行评论。

回答(1 个)

Priyank Pandey
Priyank Pandey 2023-5-15
Hi Adrian,
As I can see you're using the imresize function to resize the image to the desired input size. However, this function may introduce artifacts and distortions in the image, which can affect the accuracy of the object detection. To avoid this, you can try using a different resizing method, such as bicubic interpolation, which can provide a smoother and more accurate image.
Here's an example how you can modify the code:
I = imread(testDataTbl.imageFilename{84});
I = imresize(I,[inputSize(1) NaN]);
I = imresize(I,[NaN inputSize(2)]);
[bboxes,scores] = detect(detector,I);
I = insertObjectAnnotation(I,'rectangle',bboxes,scores);
figure
imshow(
I)
In this code, we first resize the image to the desired height using imresize(I,[inputSize(1) NaN]), then we resize it to the desired width using imresize(I,[NaN inputSize(2)]). This way, we avoid introducing artifacts and distortions in the image, which can improve the quality of the output.
I hope this helps.
Regards
Priyank
  1 个评论
Adrian Kleffler
Adrian Kleffler 2023-5-15
Hi, after trying your code this error appeared:
Error using vision.internal.cnn.validation.checkDetectionInputImage
Input image size must be greater than [224 224]. The minimum input image size must be equal to or greater than the input size in image input layer of the network.
Error in fasterRCNNObjectDetector/parseDetectInputs (line 735)
[sz,params.DetectionInputWasBatchOfImages] = vision.internal.cnn.validation.checkDetectionInputImage(...
Error in fasterRCNNObjectDetector/detect (line 523)
params = this.parseDetectInputs(I, varargin{:});

请先登录,再进行评论。

产品


版本

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by