mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-02-05 17:28:23 +08:00
add out
This commit is contained in:
parent
02f824ab1b
commit
000ee776b3
@ -252,18 +252,21 @@ void PikaCV_Image_add(PikaObj *self, PikaObj* image){
|
|||||||
/* add two images */
|
/* add two images */
|
||||||
for (i = 0; i < (src->size) / 3; i++) {
|
for (i = 0; i < (src->size) / 3; i++) {
|
||||||
result = src_data[i * 3] + img_data[i * 3];
|
result = src_data[i * 3] + img_data[i * 3];
|
||||||
src_data[i * 3] = ((result<MAX(src_data[i * 3],img_data[i * 3]))?255:result);
|
src_data[i * 3] =
|
||||||
|
((result < MAX(src_data[i * 3], img_data[i * 3])) ? 255 : result);
|
||||||
|
|
||||||
result = src_data[i * 3 + 1] + img_data[i * 3 + 1];
|
result = src_data[i * 3 + 1] + img_data[i * 3 + 1];
|
||||||
src_data[i * 3 + 1] = ((result<MAX(src_data[i * 3 + 1],img_data[i * 3 + 1]))?255:result);
|
src_data[i * 3 + 1] =
|
||||||
|
((result < MAX(src_data[i * 3 + 1], img_data[i * 3 + 1])) ? 255
|
||||||
|
: result);
|
||||||
|
|
||||||
result = src_data[i * 3 + 2] + img_data[i * 3 + 2];
|
result = src_data[i * 3 + 2] + img_data[i * 3 + 2];
|
||||||
src_data[i * 3 + 2] = ((result<MAX(src_data[i * 3 + 2],img_data[i * 3 + 2]))?255:result);
|
src_data[i * 3 + 2] =
|
||||||
|
((result < MAX(src_data[i * 3 + 2], img_data[i * 3 + 2])) ? 255
|
||||||
|
: result);
|
||||||
}
|
}
|
||||||
|
|
||||||
obj_setBytes(self, "_data", src_data, src->size);
|
obj_setBytes(self, "_data", src_data, src->size);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PikaCV_Image_minus(PikaObj* self, PikaObj* image) {
|
void PikaCV_Image_minus(PikaObj* self, PikaObj* image) {
|
||||||
@ -293,18 +296,21 @@ void PikaCV_Image_minus(PikaObj *self, PikaObj* image){
|
|||||||
/* minus two images */
|
/* minus two images */
|
||||||
for (i = 0; i < (src->size) / 3; i++) {
|
for (i = 0; i < (src->size) / 3; i++) {
|
||||||
result = src_data[i * 3] - img_data[i * 3];
|
result = src_data[i * 3] - img_data[i * 3];
|
||||||
src_data[i * 3] = ((result<MIN(src_data[i * 3],img_data[i * 3]))?0:result);
|
src_data[i * 3] =
|
||||||
|
((result < MIN(src_data[i * 3], img_data[i * 3])) ? 0 : result);
|
||||||
|
|
||||||
result = src_data[i * 3 + 1] - img_data[i * 3 + 1];
|
result = src_data[i * 3 + 1] - img_data[i * 3 + 1];
|
||||||
src_data[i * 3 + 1] = ((result>MIN(src_data[i * 3 + 1],img_data[i * 3 + 1]))?0:result);
|
src_data[i * 3 + 1] =
|
||||||
|
((result > MIN(src_data[i * 3 + 1], img_data[i * 3 + 1])) ? 0
|
||||||
|
: result);
|
||||||
|
|
||||||
result = src_data[i * 3 + 2] - img_data[i * 3 + 2];
|
result = src_data[i * 3 + 2] - img_data[i * 3 + 2];
|
||||||
src_data[i * 3 + 2] = ((result<MIN(src_data[i * 3 + 2],img_data[i * 3 + 2]))?0:result);
|
src_data[i * 3 + 2] =
|
||||||
|
((result < MIN(src_data[i * 3 + 2], img_data[i * 3 + 2])) ? 0
|
||||||
|
: result);
|
||||||
}
|
}
|
||||||
|
|
||||||
obj_setBytes(self, "_data", src_data, (src->size));
|
obj_setBytes(self, "_data", src_data, (src->size));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PikaCV_Image_merge(PikaObj* self, PikaObj* B, PikaObj* G, PikaObj* R) {
|
void PikaCV_Image_merge(PikaObj* self, PikaObj* B, PikaObj* G, PikaObj* R) {
|
||||||
@ -313,7 +319,8 @@ void PikaCV_Image_merge(PikaObj *self, PikaObj* B, PikaObj* G, PikaObj* R){
|
|||||||
PikaCV_Image* Channel_G = obj_getStruct(G, "image");
|
PikaCV_Image* Channel_G = obj_getStruct(G, "image");
|
||||||
PikaCV_Image* Channel_R = obj_getStruct(R, "image");
|
PikaCV_Image* Channel_R = obj_getStruct(R, "image");
|
||||||
|
|
||||||
if (NULL == src || NULL == Channel_B || NULL == Channel_G || NULL == Channel_R) {
|
if (NULL == src || NULL == Channel_B || NULL == Channel_G ||
|
||||||
|
NULL == Channel_R) {
|
||||||
pika_assert(0);
|
pika_assert(0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -358,12 +365,12 @@ PikaObj* PikaCV_Image_split(PikaObj *self){
|
|||||||
|
|
||||||
if (NULL == src) {
|
if (NULL == src) {
|
||||||
pika_assert(0);
|
pika_assert(0);
|
||||||
return ;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (PikaCV_ImageFormat_Type_RGB888 != src->format) {
|
if (PikaCV_ImageFormat_Type_RGB888 != src->format) {
|
||||||
obj_setErrorCode(self, PIKA_RES_ERR_OPERATION_FAILED);
|
obj_setErrorCode(self, PIKA_RES_ERR_OPERATION_FAILED);
|
||||||
__platform_printf("unsupported image format\n");
|
__platform_printf("unsupported image format\n");
|
||||||
return;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t* src_data = _image_getData(self);
|
uint8_t* src_data = _image_getData(self);
|
||||||
@ -387,7 +394,10 @@ PikaObj* PikaCV_Image_split(PikaObj *self){
|
|||||||
PikaStdData_List___init__(list);
|
PikaStdData_List___init__(list);
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
Arg* token_arg = arg_setBytes(NULL, "_data", RGB[i],src->size);
|
PikaObj* img = newNormalObj(New_PikaCV_Image);
|
||||||
|
PikaCV_Image___init__(img);
|
||||||
|
PikaCV_Image_loadGray(img, RGB[i], src->width, src->height);
|
||||||
|
Arg* token_arg = arg_setPtr(NULL, "", ARG_TYPE_OBJECT, img);
|
||||||
/* 添加到 list 对象 */
|
/* 添加到 list 对象 */
|
||||||
PikaStdData_List_append(list, token_arg);
|
PikaStdData_List_append(list, token_arg);
|
||||||
/* 销毁 arg */
|
/* 销毁 arg */
|
||||||
|
0
port/linux/test/out/path
Normal file
0
port/linux/test/out/path
Normal file
@ -9,10 +9,17 @@ R = Channel[0]
|
|||||||
G = Channel[1]
|
G = Channel[1]
|
||||||
B = Channel[2]
|
B = Channel[2]
|
||||||
|
|
||||||
img1 = cv.Image()
|
cv.Converter.toBMP(R)
|
||||||
cv.Converter.toRGB888(img1)
|
cv.Converter.toBMP(G)
|
||||||
img1.merge(R,G,B)
|
cv.Converter.toBMP(B)
|
||||||
cv.Converter.toBMP(img1)
|
R.write("test/out/R.bmp")
|
||||||
img1.write("test/assets/merge.bmp")
|
G.write("test/out/G.bmp")
|
||||||
|
B.write("test/out/B.bmp")
|
||||||
|
|
||||||
print("Merge done")
|
# img1 = cv.Image()
|
||||||
|
# cv.Converter.toRGB888(img1)
|
||||||
|
# img1.merge(R,G,B)
|
||||||
|
# cv.Converter.toBMP(img1)
|
||||||
|
# img1.write("test/assets/merge.bmp")
|
||||||
|
|
||||||
|
# print("Merge done")
|
Loading…
x
Reference in New Issue
Block a user