# %% from ORSModel import Channel, orsObj, Progress, MultiROI, ArrayUnsignedLong, Color import numpy as np from matplotlib import pyplot as plt #%% multi_roi = orsObj('F3EE6FB4E7BA4A08A733B7963349EA2BCxvLabeledMultiROI') preview = orsObj('3F9C5390478C4A5B99BA5F47A2DE39EACxvLabeledMultiROI') #%% # multi_roi_array = multi_roi.getAsArray(tIndex=1,) # multi_roi_array = np.zeros((1,644,644)) # multi_roi_array = multi_roi.getNDArray() # multi_roi_array = ArrayUnsignedLong() # multi_roi.getAsArray(tIndex=0,pOutputArray=multi_roi_array) # Convert both the multi ROI and preview ROI to numpy arrays multi_roi_channel = Channel() multi_roi_progress = Progress() multi_roi.getAsChannel(inOutStructuredGrid=multi_roi_channel, IProgress=multi_roi_progress) multi_roi_array = multi_roi_channel.getNDArray() preview_channel = Channel() preview_progress = Progress() preview.getAsChannel(inOutStructuredGrid=preview_channel, IProgress=preview_progress) preview_array = preview_channel.getNDArray() #%%
#%% from ORSModel import Channel,orsObj import numpy as np from matplotlib import pyplot as plt # %% xrf_channel = orsObj('2DD11443C547404A9C115E7BAFEDB166CxvChannel') #%% xrf_array = xrf_channel.getNDArray() xrf_array = xrf_array.swapaxes(0,2) xrf_array = xrf_array.squeeze() # xrf_array = xrf_array.reshape(xrf_array.shape[0]*xrf_array.shape[1]) print(xrf_array.shape) #%% hist = np.histogram(xrf_array,bins=5) print(hist) #%% bins = np.linspace(0,255,6) inds = np.digitize(xrf_array,bins)
# %% import numpy as np from ORSModel import Channel, orsObj #%% def save_channel_to_numpy(obj_id): data_channel = obj_id data_array = data_channel.getNDArray() print(data_array.shape) np.save('data', data_array) #%% #! USER INPUT save_channel_to_numpy(orsObj('51C5EF1F95C742E2A12E6A42AF671C68CxvChannel'))
# %% from ORSModel import Channel, orsObj import numpy as np from matplotlib import pyplot as plt # %% xrf_channel = orsObj('51C5EF1F95C742E2A12E6A42AF671C68CxvChannel') #%% crop #%% xrf_stack = xrf_channel.getNDArray() xrf_stack = xrf_stack.swapaxes(0, 2) print(xrf_stack.shape) #%% # fig = plt.figure() # plt.imshow(xrf_stack[:,:,0]) # plt.show() #%% #! USER INPUT thresh = 255 binary = np.zeros_like(xrf_stack) print(binary.shape) #%% for i in range(xrf_stack.shape[2]): for j in range(xrf_stack.shape[1]): for k in range(xrf_stack.shape[0]): if xrf_stack[k, j, i] >= thresh: binary[k, j, i] = 1
# %% from ORSModel import Channel, orsObj import numpy as np # %% red_channel = orsObj('9DB0BBDD9C0E4661B71C15ABC91C9050CxvChannel') green_channel = orsObj('C691EEA1AC0A4470994971A2408A8665CxvChannel') blue_channel = orsObj('72E031C786C849B9AF953AB9EAFF0376CxvChannel') bins = np.linspace(0, 255, 4) clusters = 8 # spacing = # channel = Channel() # #set it sizes, since we use the default voxel size, the channel is for now 100 meter cube # channel.setXYZTSize(100,100,100,1) # channel.setXSpacing(0.01) # channel.setYSpacing(0.01) # channel.setZSpacing(0.01) # #now the channel is 1 meter cube # #initilize it for float32 data # channel.initializeDataForFLOAT() # #publish it so that it is visible in the Object properties list # channel.publish() # %% # array = channel.getNDArray() # #modify it data