如何更改图像的rgb组件的值

时间:2016-06-10 10:30:02

标签: python-3.x tkinter

我想解析图像的r,g,b矩阵进行更改,然后再将它们应用到图像上。我使用public class myFirebaseMessagingService extends FirebaseMessagingService { private static final String TAG="MyFirebaseMsgService"; @Override public void onMessageReceived(RemoteMessage remoteMessage) { super.onMessageReceived(remoteMessage); Log.d(TAG, "From " + remoteMessage.getFrom()); Log.d(TAG, "Body " + remoteMessage.getNotification().getBody()); sendNotification(remoteMessage); Log.d("Msg", "Poruka je stigla"); } private void sendNotification(RemoteMessage remoteMessage){ Intent intent=new Intent(myFirebaseMessagingService.this, MainActivity.class); intent.putExtra("action", "goToFragment1"); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent=PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notification=new NotificationCompat.Builder(this) .setSmallIcon(logo) .setContentText(remoteMessage.getNotification().getBody()) .setContentTitle("Naslov") .setAutoCancel(true) .setSound(defaultSoundUri) .setContentIntent(pendingIntent); NotificationManager notificationManager=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(0, notification.build()); } 函数来显示图像:

PhotoImage

这会返回每个像素的rgb值,但我无法对图像的像素值进行更改。
我尝试使用img=Photoimage(filename) for i in range (0,500): for j in range (0,500): pixel=img.get(i,j) load()imread()getpixel() ..但这些似乎与Python 3无关。
有什么建议吗?

1 个答案:

答案 0 :(得分:0)

我过去曾使用PIL执行此操作,这是我使用的代码,它将其作为单个值而不是RGB读取,因为它似乎只适用于GIF:

JoinTable

希望这有帮助。