简体   繁体   中英

CNN Classification Keras Frames

For the classification of good as well as bad condition I recorded the frequencies with my sensors. Then I plotted the data in the form of a spoctrogram. I will then classify these in the form of a CNN. But unfortunately I made a mistake when creating frames and now I have to edit all the frames (5000). And I only need a section of the pictures.

在此处输入图像描述

I only need the range of the spectrogram for a qualitative classification.

If I understand correctly you want to crop the image, taking the center portion of it. If the images are of same size you can slice them like this (the numbers are just to give an example):

y0 = 10  # the y top coordinate of the rectangle to extract
height = 40  # the height of the rectangle you want to extract
x0 = 10  # the x left coordinate of the rectangle
width = 20  # the width of the rectangle
# img is the newly cropped image
img = x[y0:y0+height,x0:x0+width, :]

Important note: when setting the x0 and y0 coordinates, you have to give the position of the top left corner of the rectangle you want to crop. Also the origin O of the coordinate system, is at the top left corner of the image.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM