ImageMake

import numpy as np    
from math import *    
import sys    
import os    
import glob    
import argparse    
import cv2 as cv   
import keras
import random
from matplotlib import pyplot as plt
def onmouse(event, x, y, flags, param):#鼠标事件响应函数    
    global drag_start, sel, lab, sets, count 
    if event == cv.EVENT_LBUTTONDOWN:#左键按下时记录当前初始坐标,并初始化矩形sel    
        drag_start = x, y    
        sel = 0,0,0,0   
        sam=0,0,0,0   
        if count==100:
            lab+=1
        if count==200:
            lab+=1
        if count>=300:
            print('over all')
        count+=1
    elif event == cv.EVENT_LBUTTONUP:#鼠标左键叹弹起时响应    
        if sel[2] > sel[0] and sel[3] > sel[1]:#判断右下角坐标是否大于左上角   
            mid=int((sel[1]+sel[3])/2),int((sel[0]+sel[2])/2)
            sam=mid[0]-14,mid[1]-14,mid[0]+14,mid[1]+14
            patch = gray[sam[0]:sam[2],sam[1]:sam[3]]#取矩形区域内像素作为patch图像  
            target = cv.cvtColor(patch, cv.COLOR_GRAY2BGR)#取矩形区域内原始像素截取图像 
            #sets.append([target,int(input('lab:'))])
            sets.append([target,lab])
            print(target.shape,sam,count,lab,sam[0],sam[1],sam[2],sam[3])
            np.save('cloud',sets)
            #plt.imsave('sample.jpg',target)
        drag_start = None    
    elif drag_start:    
        #print flags    
        if flags & cv.EVENT_FLAG_LBUTTON:#取当前坐标与初始坐标较小的为矩形坐标左上,较大的为右下    
            minpos = min(drag_start[0], x), min(drag_start[1], y)    
            maxpos = max(drag_start[0], x), max(drag_start[1], y)    
            sel = minpos[0], minpos[1], maxpos[0], maxpos[1]    
            img = cv.cvtColor(gray, cv.COLOR_GRAY2BGR)    
            cv.rectangle(img, (sel[0], sel[1]), (sel[2], sel[3]), (0,255,255), 1)    
            #print(sel[0],sel[1],sel[2],sel[3])
            cv.imshow("gray", img)    
        else:    
            print ("selection is complete" )
            drag_start = None    

drag_start = None#全局变量取方块鼠标拖拽时使用    
sel = (0,0,0,0)#全局变量 长方形左上颌右下定点坐标存储    
lab=0
sets=[]  
count=0
#filename = 'HC421.jpg'   
filename = 'up.jpg'   
cv.namedWindow("gray",1) # 第二个参数 1窗口固定;2窗口可调整   
cv.setMouseCallback("gray", onmouse)     
 
ext = os.path.splitext(filename)[1][1:] #get the filename extenstion    
if ext == "png" or ext == "jpg" or ext == "bmp" or ext == "tiff" or ext == "pbm":    
    print (filename )   
                
    img=cv.imread(filename,1)    
    sel = (0,0,0,0)    
    drag_start = None    
    gray=cv.cvtColor(img, cv.COLOR_BGR2GRAY)    
    cv.imshow("gray",gray)    
    cv.waitKey(0)
 
cv.destroyAllWindows()   

v2

# coding:utf-8
import numpy as np    
from math import *    
import sys    
import os    
import glob    
import argparse    
import cv2 as cv  
import random
import pickle
from libtiff import TIFF
from scipy import misc
from matplotlib import pyplot as plt
imagename='../../湖泊陆地植被-平原/1182801/HJ1A-CCD1-453-76-20140728-L20001182801-'
image=np.array([TIFF.open(imagename+str(i+1)+'.TIF', mode='r').read_image() for i in range(4)])
image_hwc = np.transpose(image, (1, 2, 0))
data = np.zeros([1,28,28,4])
print('image_hwc.shap....................................................',image_hwc.shape)

filename = 'test_gyy.jpg'  
image_hwc=cv.imread(filename,1)

def onmouse(event, x, y, flags, param):#鼠标事件响应函数    
    global drag_start, sel, times, sets, count 
    if event == cv.EVENT_LBUTTONDOWN:#左键按下时记录当前初始坐标,并初始化矩形sel    
        drag_start = x, y    
        sel = 0,0,0,0   
        sam=0,0,0,0   
        count+=1
    elif event == cv.EVENT_LBUTTONUP:#鼠标左键叹弹起时响应    
        if sel[2] > sel[0] and sel[3] > sel[1]:#判断右下角坐标是否大于左上角   
            mid=int((sel[1]+sel[3])/2),int((sel[0]+sel[2])/2)
            sam=mid[0]-14*times,mid[1]-14*times,mid[0]+14*times,mid[1]+14*times
            #patch = gray[sam[0]:sam[2],sam[1]:sam[3]]#取矩形区域内像素作为patch图像  
            patch = image_hwc[sam[0]:sam[2],sam[1]:sam[3],:]#取矩形区域内像素作为patch图像
            
            for i in range(times):
                for j in range(times):
                    sets.append(patch[i*28:(i+1)*28,j*28:(j+1)*28])
            
            print('patch.shape:',patch.shape,'times:',times,sam,count,sam[0],sam[1],sam[2],sam[3])
            
            #target = cv.cvtColor(patch, cv.COLOR_GRAY2BGR)#取矩形区域内原始像素截取图像 
            #sets.append([target,int(input('lab:'))])
            #sets.append(patch)
            cv.imwrite('./dataset_zx/buf_ori.jpg',patch)
            np.save('./dataset_zx/thickcloud_2',sets)
            #plt.imsave('sample.jpg',target)
        drag_start = None    
    elif drag_start:    
        #print flags    
        if flags & cv.EVENT_FLAG_LBUTTON:#取当前坐标与初始坐标较小的为矩形坐标左上,较大的为右下    
            minpos = min(drag_start[0], x), min(drag_start[1], y)    
            maxpos = max(drag_start[0], x), max(drag_start[1], y)    
            sel = minpos[0], minpos[1], maxpos[0], maxpos[1]    
            img = cv.cvtColor(gray, cv.COLOR_GRAY2BGR)    
            cv.rectangle(img, (sel[0], sel[1]), (sel[2], sel[3]), (0,255,255), 1)    
            #print(sel[0],sel[1],sel[2],sel[3])
            cv.imshow("gray", img)    
        else:    
            print ("selection is complete" )
            drag_start = None    

drag_start = None#全局变量取方块鼠标拖拽时使用    
sel = (0,0,0,0)#全局变量 长方形左上颌右下定点坐标存储    
times=5
sets=[]  
count=0  
filename = 'test_gyy.jpg'   
cv.namedWindow("gray",1) # 第二个参数 1窗口固定;2窗口可调整   
cv.setMouseCallback("gray", onmouse)     
 
ext = os.path.splitext(filename)[1][1:] #get the filename extenstion    
if ext == "png" or ext == "jpg" or ext == "bmp" or ext == "tiff" or ext == "pbm":    
    print (filename )   
                
    img=cv.imread(filename,1)    
    print('img.shape:',img.shape)
    sel = (0,0,0,0)    
    drag_start = None    
    gray=cv.cvtColor(img, cv.COLOR_BGR2GRAY)    
    cv.imshow("gray",gray)    
    cv.waitKey(0)
 
cv.destroyAllWindows()  

test

#split patch
for i in range(times):
    cv.imwrite('./dataset_zx/' + str(i) + '.png', test[i])

def fill_buf(buf, i, img, shape):
    '''fill the ith grid of the buffer matrix with the values from the img
    buf : buffer matrix
    i : serial of the image in the 2D grid
    img : image data
    shape : ( height width depth ) of image'''

    # grid height is a multiple of individual image height
    m = buf.shape[0]/shape[0]

    sx = (i%m)*shape[1]
    sy = (i//m)*shape[0]
    sx = int(sx)
    sy = int(sy)
    buf[sy:sy+shape[0], sx:sx+shape[1], :] = img
   
n = np.ceil(np.sqrt(test.shape[0]))
buff = np.zeros((int(n*test.shape[1]), int(n*test.shape[2]), int(test.shape[3])), dtype=np.uint8)
for i, img in enumerate(test):
    fill_buf(buff, i, img, test.shape[1:3])
cv.imwrite('./dataset_zx/%s.jpg' % 'buf', buff)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
<builders> <org.jenkinsci.plugins.conditionalbuildstep.singlestep.SingleConditionalBuilder plugin="conditional-buildstep@1.4.2"> <condition class="org.jenkins_ci.plugins.run_condition.contributed.ShellCondition" plugin="run-condition@1.5"> <command>if git show --summary HEAD | grep -q -E "\(cherry picked from commit \b[0-9a-f]{5,40}\b\)"; then exit 1 fi</command> </condition> <buildStep class="hudson.tasks.Shell"> <command>./scripts/checkpatch.pl --min-conf-desc-length=1 --ignore GERRIT_CHANGE_ID -g HEAD </command> <configuredLocalRules/> </buildStep> <runner class="org.jenkins_ci.plugins.run_condition.BuildStepRunner$Run" plugin="run-condition@1.5"/> </org.jenkinsci.plugins.conditionalbuildstep.singlestep.SingleConditionalBuilder> <hudson.tasks.Shell> <command>NCPU=$(expr $(nproc --all ) / 2) make O=build-${BUILD_ID} -s defconfig make O=build-${BUILD_ID} -j$NCPU -s Image make O=build-${BUILD_ID} -j$NCPU -s modules make O=build-${BUILD_ID} INSTALL_MOD_PATH=../install-${BUILD_ID} -s modules_install mkdir -p install-${BUILD_ID}/boot/ KERNELVER=$(cat build-${BUILD_ID}/include/config/kernel.release 2> /dev/null) cat build-${BUILD_ID}/arch/arm64/boot/Image > install-${BUILD_ID}/boot/Image-$KERNELVER cp build-${BUILD_ID}/System.map install-${BUILD_ID}/boot/System.map-$KERNELVER cp build-${BUILD_ID}/.config install-${BUILD_ID}/boot/config-$KERNELVER tar -cJf install-${BUILD_ID}/linux-$KERNELVER.tar.xz -C install-${BUILD_ID}/ boot lib</command> <configuredLocalRules/> </hudson.tasks.Shell> <hudson.tasks.Shell> <command>cd $HOME/src/linux git fetch -p -t git pull </command> <configuredLocalRules/> </hudson.tasks.Shell> </builders> 这是一段Jenkins job的定义,请把它转成对应的JJB的yaml格式配置文件
最新发布
07-15
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值