0

I need help to understand how to downsample a matrix from an image to a matrix of 10x10.

Libraries:

import sys
import cv2
import numpy
from PIL import Image
from numpy import array

I used PIL to get the image and used numpy to get the matrix array

im_1 = Image.open(r"C:\Users\DELL\Downloads\FaceDataset\s1\1.pgm")
ar = array(im_1)
numpy.set_printoptions(threshold=sys.maxsize)
print("Orignal Image Matrix")
print(ar)

output:

[[ 48  49  45  47  49  57  39  42  53  49  53  60  76  91  99  95  80  75
   66  54  47  49  50  43  46  53  61  70  84 105 133 130 110  94  81 107
   95  80  57  55  66  86  80  74  65  71  62  84  52  74  71  67  64  88
   68  71  75  66  57  61  62  52  47  50  58  60  64  66  57  46  54  66
   80  80  68  71  87  64  77  66  83  77  58  46  41  43  56  55  51  56
   56  54]

this is not the complete output. how can i downsample this into a 10x10 matrix? note: i used opencv to use the "pyrDown"but it didn't give the output i need

1 Answers1

0

I solved it by image slicing method in 2d array

dsAr = ar[::12, ::10]
print(dsAr)

note: slicing notation is => start:stop:step