Python Forum
hatching based of maximum of 3 different arrays
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
hatching based of maximum of 3 different arrays
#1
I have three numpy arrays

A.shape = 72 X 144
B.shape = 72 X 144
C.shape = 72 X 144

I want to create one color map from these arrays where regions in which A is the greatest of the three will be hatched or colored red, regions where B is the max of the three will be hatched as greed and regions where C is the max blue




thanks
Reply
#2
untested
import numpy as np

A = np.random.randint(0, 255, size=(72,144))
B = np.random.randint(0, 255, size=(72,144))
C = np.random.randint(0, 255, size=(72,144))

colormap = np.zeros((72,144,3), dtype='uint8')
colormap[(A>B) & (A>C),0] = 255 # red
colormap[(B>A) & (B>C),1] = 255 # green
colormap[(C>A) & (C>B),2] = 255 # blue
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  hatching not working properly with matplotlib Staph 3 2,950 Jul-28-2019, 07:17 AM
Last Post: ThomasL

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020