// -*- C++ -*- /* Copyright 2007 Deutsches Forschungszentrum fuer Kuenstliche Intelligenz or its licensors, as applicable. You may not use this file except under the terms of the accompanying license. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http: www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Project: File: Purpose: Responsible: tmb Reviewer: Primary Repository: Web Sites: www.iupr.org, www.dfki.de */ $#include "narray.h" $#include "coords.h" $#include "imgbits.h" $#include "imgrle.h" $ using namespace colib; $ using namespace imgbits; $ using namespace imgrle; module bits { struct BitImage { BitImage(); BitImage(int w,int h); ~BitImage(); void clear(); void copy(BitImage &other); int rank(); int dim(int i); void resize(int w,int h); word32 *get_line(int i); bool at(int i,int j); void set_bit(int i,int j); void clear_bit(int i,int j); void set(int i,int j,bool value); void fill(bool value); double megabytes(); }; void bits_move @ move(BitImage &dest,BitImage &src); void bits_convert @ convert(BitImage &bimage,bytearray &image); void bits_convert @ convert(BitImage &bimage,floatarray &image); void bits_convert @ convert(bytearray &image,BitImage &bimage); void bits_convert @ convert(floatarray &image,BitImage &bimage); int bits_count_rect @ count_rect(BitImage &image,int x0=0,int y0=0,int x1=32000,int y1=32000); void bits_set_rect @ set_rect(BitImage &image,int x0=0,int y0=0,int x1=32000,int y1=32000,bool value=false); void bits_resample_normed @ resample_normed(bytearray &image,BitImage &bits,int vis_scale,bool norm=true); void bits_resample @ resample(bytearray &image,BitImage &bits,int vis_scale); void bits_reduce2_and @ reduce2_and(BitImage &out,BitImage &image); void bits_transpose @ transpose(BitImage &out,BitImage &in); void bits_transpose @ transpose(BitImage &image); void bits_flip_v @ flip_v(BitImage &image); void bits_flip_h @ flip_h(BitImage &image); void bits_rotate_rect @ rotate_rect(BitImage &image,int angle); void bits_set @ set(BitImage &image,BitImage &other,int dx=0,int dy=0); void bits_setnot @ setnot(BitImage &image,BitImage &other,int dx=0,int dy=0); void bits_and @ And(BitImage &image,BitImage &other,int dx=0,int dy=0); void bits_or @ Or(BitImage &image,BitImage &other,int dx=0,int dy=0); void bits_andnot @ andnot(BitImage &image,BitImage &other,int dx=0,int dy=0); void bits_ornot @ ornot(BitImage &image,BitImage &other,int dx=0,int dy=0); void bits_xor @ xor(BitImage &image,BitImage &other,int dx=0,int dy=0); void bits_invert @ invert(BitImage &image); void bits_skew @ skew(BitImage &image,float skew,float center=0.0,bool backwards=false); void bits_rotate @ rotate(BitImage &image,float angle); void bits_erode_rect @ erode_rect(BitImage &image,int rx,int ry); void bits_dilate_rect @ dilate_rect(BitImage &image,int rx,int ry); void bits_open_rect @ open_rect(BitImage &image,int rx,int ry); void bits_close_rect @ close_rect(BitImage &image,int rx,int ry); void bits_erode_mask @ erode_mask(BitImage &image,BitImage &element,int cx=DFLTC,int cy=DFLTC); void bits_dilate_mask @ dilate_mask(BitImage &image,BitImage &element,int cx=DFLTC,int cy=DFLTC); void bits_open_mask @ open_mask(BitImage &image,BitImage &element,int cx=DFLTC,int cy=DFLTC); void bits_close_mask @ close_mask(BitImage &image,BitImage &element,int cx=DFLTC,int cy=DFLTC); void bits_mask_hitmiss @ mask_hitmiss(BitImage &image,BitImage &element,int cx=DFLTC,int cy=DFLTC); void bits_mask_hitmiss @ mask_hitmiss(BitImage &image,BitImage &hit,BitImage &miss,int cx=DFLTC,int cy=DFLTC); void bits_circ_mask @ circ_mask(BitImage &image,int r); void bits_erode_circ @ erode_circ(BitImage &image,int r); void bits_dilate_circ @ dilate_circ(BitImage &image,int r); void bits_open_circ @ open_circ(BitImage &image,int r); void bits_close_circ @ close_circ(BitImage &image,int r); void bits_erode_rrect @ erode_rrect(BitImage &image,int w,int h,double angle); void bits_dilate_rrect @ dilate_rrect(BitImage &image,int w,int h,double angle); void bits_open_rrect @ open_rrect(BitImage &image,int w,int h,double angle); void bits_close_rrect @ close_rrect(BitImage &image,int w,int h,double angle); void bits_erode_line @ erode_line(BitImage &image,int r,double angle,int rp); void bits_dilate_line @ dilate_line(BitImage &image,int r,double angle,int rp); void bits_open_line @ open_line(BitImage &image,int r,double angle,int rp); void bits_close_line @ close_line(BitImage &image,int r,double angle,int rp); // mainly for benchmarking void bits_erode_rect_bruteforce @ erode_rect_bruteforce(BitImage &image,int rx,int ry); void bits_dilate_rect_bruteforce @ dilate_rect_bruteforce(BitImage &image,int rx,int ry); void bits_erode_mask_bruteforce @ erode_mask_bruteforce(BitImage &image,BitImage &element,int cx,int cy); void bits_dilate_mask_bruteforce @ dilate_mask_bruteforce(BitImage &image,BitImage &element,int cx,int cy); void bits_erode_circ_by_dt @ erode_circ_by_dt(BitImage &image,int r); void bits_erode_line_by_mask @ erode_line_by_mask(BitImage &image,int r,double angle); void bits_dilate_line_by_mask @ dilate_line_by_mask(BitImage &image,int r,double angle); void bits_open_line_by_mask @ open_line_by_mask(BitImage &image,int r,double angle); void bits_close_line_by_mask @ close_line_by_mask(BitImage &image,int r,double angle); void bits_runlength_statistics @ runlength_statistics(floatarray &on,floatarray &off,BitImage &image); void bits_read @ read(BitImage &image,const char *file); void bits_write @ write(const char *file,BitImage &image); void bits_dshow @ dshow(BitImage &image, const char *spec=""); void bits_thin @ thin(BitImage &image,int neighborhood); void bits_parse_mask @ parse_mask(BitImage &hit,const char *mask); void bits_parse_hitmiss @ parse_hitmiss(BitImage &hit,BitImage &miss,const char *mask); extern int use_telescope; void bits_change_blit @ change_blit(int); int get_blit_count(); } $[ -- BitImage = bits.BitImage -- deprecated because everything's in modules now function bits.readnew(file) local bi = BitImage() bits.read(bi, file) return bi end $]